<template>
	<div class="throm-report">
		<div class="report-container">
			<a-row >
				<a-col :span="24">
					<a-card class="report-card baseInfo" title="患者信息">
						<a-col :span='8'>
							<a-row><div class="leftTitle">姓名</div><div class="rightValue">{{patient.patientName}}</div></a-row>
							<a-row><div class="leftTitle">民族</div><div class="rightValue">{{patient.patientNation || '-'}}</div></a-row>
							<a-row><div class="leftTitle">诊断</div><div class="rightValue">{{patient.firstAidZlTypeString || '-'}}</div></a-row>
						</a-col>
						<a-col :span='8' class="midItem">
							<a-row><div class="leftTitle">性别</div><div class="rightValue">{{patient.patientGenderString || '-'}}</div></a-row>
							<a-row><div class="leftTitle">身份证号</div><div class="rightValue">{{patient.patientIdCardNo ? utils.maskIDCard(patient.patientIdCardNo || '') : '-'}}</div></a-row>
							<a-row><div class="leftTitle">发病时间</div><div class="rightValue">{{queryItemInfo('XGZL-CCWC-TIME').toString() ||'-'}}</div></a-row>
						</a-col>
						<a-col :span='8'>
							<a-row><div class="leftTitle">年龄</div><div class="rightValue">{{patient.patientAge || '-'}}岁</div></a-row>
							<a-row><div class="leftTitle">联系方式</div><div class="rightValue">{{patient.patientContract || '-'}}</div></a-row>
						
						</a-col>
					</a-card>

				</a-col>
				<a-col :span="24">
					<a-card class="report-card baseInfo" title="病情评估">
						<a-col :span='8'>
							<a-row><div class="leftTitle">入院mRS评分</div><div class="rightValue">{{ getFirstInfo['RYPG-MRS'] || '暂无' }}</div></a-row>
							<a-row><div class="leftTitle">入院NIHSS评分</div><div class="rightValue">{{ getFirstInfo['RYPG-NIHSS'] || '暂无' }}</div></a-row>
							<a-row><div class="leftTitle">舒张压/收缩压</div><div class="rightValue">
								<span>{{getFirstInfo['RYPG-DIASTOLIC-PRESSURE'] ? (getFirstInfo['RYPG-DIASTOLIC-PRESSURE'] + 'mmHg') : '暂无'}}</span>
									<span> / </span>
									<span>{{getFirstInfo['RYPG-SYSTOLIC-PRESSURE'] ? (getFirstInfo['RYPG-SYSTOLIC-PRESSURE'] + 'mmHg') : '暂无'}}</span>
							</div></a-row>
							<a-row><div class="leftTitle">选用平车</div><div class="rightValue">{{patient.carNo || '-'}}</div></a-row>
							<a-row><div class="leftTitle">绿道状态</div><div class="rightValue"><span class="report-treat-rowtext"><a-switch checked></a-switch></span></div></a-row>
						</a-col>
						<a-col :span='8' class="midItem">
							<a-row><div class="leftTitle">身高</div><div class="rightValue">{{ getFirstInfo['RYPG-HEIGHT'] ? getFirstInfo['RYPG-HEIGHT'] + 'CM' : '暂无' }}</div></a-row>
							<a-row><div class="leftTitle">体重</div><div class="rightValue">{{ getFirstInfo['RYPG-WEIGHT'] ? getFirstInfo['RYPG-WEIGHT'] + 'KG' : '暂无' }}</div></a-row>
							<a-row><div class="leftTitle">BMI</div><div class="rightValue">{{ getFirstInfo['RYPG-BMI'] || '暂无' }}</div></a-row>
							<a-row><div class="leftTitle">血糖</div><div class="rightValue">{{ getFirstInfo['RYPG-PULSE'] ? getFirstInfo['RYPG-PULSE'] + '次/分' : '暂无' }}</div></a-row>
						</a-col>
						<a-col :span='8'>
							<a-row><div class="leftTitle">选用平车</div><div class="rightValue">{{patient.carNo || '-'}}</div></a-row>
							<a-row><div class="leftTitle">溶栓药物</div><div class="rightValue">: {{getFirstInfo['JMRS-RSYW'] || '暂无'}}</div></a-row>
							<a-row><div class="leftTitle">静滴剂量</div><div class="rightValue">:  {{getFirstInfo['JMRS-JDJL'] || '暂无'}}</div></a-row>
							<a-row><div class="leftTitle">团注剂量</div><div class="rightValue">: {{getFirstInfo['JMRS-TZJL'] || '暂无'}}</div></a-row>						
						</a-col>
					</a-card>
				</a-col>
				<a-col :span="24">
					<a-card class="report-card" title="溶栓状态">
						<div class="report-timeline">
							<a-steps progress-dot :current="currentIndex" direction="vertical">
								<template v-for="(item, index) in getNodeList">
									<a-step
										:status="processNodeIndex == index ? 'process' : processNodeIndex > index && item.record ? 'finish' : 'wait' ">
										<div slot="title"
											style="display: flex;justify-content: space-between;width: 100%">
											<div>{{item.nodeName}}</div>
											<div>
												{{processNodeIndex == index ? '进行中' : processNodeIndex > index && item.record ? '已完成' : ''}}
											</div>
										</div>
										<div slot="description">{{item.record ? item.record.answer[0] : ''}}</div>
									</a-step>
								</template>
							</a-steps>
						</div>
					</a-card>
				</a-col>
				<a-col :span="24">
					<a-card class="report-card" title="急诊溶栓记录">
						<a slot="extra" id="exportFirst" href="JavaScript:;" @click="handleExportRsPdf">导出</a>
						<div class="report-card-content" style="min-height: 300px;">
							<div class="record-content" v-html="recordData"></div>
							<div class="emtpy" v-if="!recordData">
								<a-empty :image="emptyImage" description="暂无溶栓记录" />
							</div>
						</div>
					</a-card>
				</a-col>
				<a-col :span="24">
					<a-card class="report-card" title="溶栓观察表">
						<a slot="extra" href="javascript:;" @click="handleExportRsgcbPdf">导出</a>
						<div class="doc-ct-content">
							<div>
								<table border class="report-rsgcb">
									<!-- <tr>
										<td>姓名：{{patient.patientName}}</td>
										<td>性别：{{patient.patientGenderString}}</td>
										<td>年龄：{{patient.patientAge}}</td>
										<td>诊断： {{patient.firstAidZlType}}</td>
										<td>观察者： </td>
									</tr>
									<tr>
										<td colspan="3">发病时间：{{queryItemInfo('XGZL-CCWC-TIME').toString()}}</td>
										<td colspan="3">用药时间：{{queryItemInfo('RYPG-CBZD').toString()}}</td>
									</tr> -->
									<tr>
										<td colspan="2">溶栓药物：{{queryItemInfo('JMRS-RSYW').toString()}}</td>
										<td colspan="2">剂量：{{queryItemInfo('JMRS-JDJL').toString()}}</td>
										<td colspan="2">用法用量： </td>
									</tr>
									<tr>
										<td>时间点</td>
										<td>血压(BP)</td>
										<td>心率(HR)</td>
										<td>血样饱和度(HR)</td>
										<td>格拉斯评分</td>
										<td>NIHSS</td>
									</tr>
									<tr>
										<td>用药前</td>
										<td>{{queryItemInfo('JMRS-Q-SYSTOLIC-PRESSURE').toString()}}</td>
										<td></td>
										<td></td>
										<td></td>
										<td>{{queryItemInfo('JMRS-Q-NIHSS').toString()}}</td>
									</tr>
									<tr>
										<td>15min</td>
										<td>{{queryItemInfo('JMRS-15-SYSTOLIC-PRESSURE').toString()}}</td>
										<td></td>
										<td></td>
										<td></td>
										<td>{{queryItemInfo('JMRS-15-NIHSS').toString()}}</td>
									</tr>
									<tr>
										<td>30min</td>
										<td>{{queryItemInfo('JMRS-30-SYSTOLIC-PRESSURE').toString()}}</td>
										<td></td>
										<td></td>
										<td></td>
										<td>{{queryItemInfo('JMRS-30-NIHSS').toString()}}</td>
									</tr>
									<tr>
										<td>45min</td>
										<td>{{queryItemInfo('JMRS-45-SYSTOLIC-PRESSURE').toString()}}</td>
										<td></td>
										<td></td>
										<td></td>
										<td>{{queryItemInfo('JMRS-45-NIHSS').toString()}}</td>
									</tr>
									<tr>
										<td>60min</td>
										<td>{{queryItemInfo('JMRS-60-SYSTOLIC-PRESSURE').toString()}}</td>
										<td></td>
										<td></td>
										<td></td>
										<td>{{queryItemInfo('JMRS-60-NIHSS').toString()}}</td>
									</tr>
									<tr>
										<td>75min</td>
										<td>{{queryItemInfo('JMRS-75-SYSTOLIC-PRESSURE').toString()}}</td>
										<td></td>
										<td></td>
										<td></td>
										<td>{{queryItemInfo('JMRS-75-NIHSS').toString()}}</td>
									</tr>
									<tr>
										<td>90min</td>
										<td>{{queryItemInfo('JMRS-90-SYSTOLIC-PRESSURE').toString()}}</td>
										<td></td>
										<td></td>
										<td></td>
										<td>{{queryItemInfo('JMRS-90-NIHSS').toString()}}</td>
									</tr>
									<tr>
										<td>105min</td>
										<td>{{queryItemInfo('JMRS-105-SYSTOLIC-PRESSURE').toString()}}</td>
										<td></td>
										<td></td>
										<td></td>
										<td>{{queryItemInfo('JMRS-105-NIHSS').toString()}}</td>
									</tr>
									<tr>
										<td>120min</td>
										<td>{{queryItemInfo('JMRS-120-SYSTOLIC-PRESSURE').toString()}}</td>
										<td></td>
										<td></td>
										<td></td>
										<td>{{queryItemInfo('JMRS-120-NIHSS').toString()}}</td>
									</tr>
								</table>
							</div>
						</div>
					</a-card>
				</a-col>
				<a-col :span="24">
					<a-card class="report-card" title="DNT时间表">
						<a slot="extra" href="javascript:;" @click="handleExportDntPdf">导出</a>
						<div class="doc-ct-content">
							<div class="record-content">
								<table border class="report-rsgcb">
									<!-- <tr>
										<td colspan="2">姓名：{{patient.patientName}}</td>
										<td colspan="3">性别：{{patient.patientGenderString}}</td>
										<td colspan="1">年龄：{{patient.patientAge}}</td>
										<td colspan="2">血糖(BS)：{{queryItemInfo('RYPG-BLOOD-SUGAR').toString()}}</td>
										<td colspan="2">血压(BP)：{{queryItemInfo('JMRS-Q-SYSTOLIC-PRESSURE').toString()}}
										</td>
									</tr>
									<tr>
										<td colspan="3">一线：</td>
										<td colspan="3">二线：</td>
										<td colspan="4">NIHSS：{{queryItemInfo('JMRS-Q-NIHSS').toString()}}</td>
									</tr> -->
									<tr>
										<td colspan="2">溶栓流程</td>
										<td colspan="3">具体时间</td>
										<td colspan="2">采集方式</td>
										<td colspan="3">备注</td>
									</tr>
									<tr>
										<td colspan="2">发病时间</td>
										<td colspan="3">{{queryItemInfo('JBXX-FBSJ').toString()}}</td>
										<td colspan="2"></td>
										<td colspan="3"></td>
									</tr>
									<tr>
										<td colspan="2">到院时间</td>
										<td colspan="3">{{queryItemInfo('JBXX-FBSJ').toString()}}</td>
										<td colspan="2">质控平车：</td>
										<td colspan="3"></td>
									</tr>
									<tr>
										<td colspan="2">启动绿道时间</td>
										<td colspan="3">{{queryItemInfo('RYPG-GR-TIME').toString()}}</td>
										<td colspan="2">可视化信息竖屏：</td>
										<td colspan="3"></td>
									</tr>
									<tr>
										<td colspan="2">呼叫时间</td>
										<td colspan="3">{{queryItemInfo('JBXX-TZCZYS-TIME').toString()}}</td>
										<td colspan="2"></td>
										<td colspan="3"></td>
									</tr>
									<tr>
										<td colspan="2">一线到场时间</td>
										<td colspan="3">{{queryItemInfo('JBXX-CZYSDC-TIME').toString()}}</td>
										<td colspan="2"></td>
										<td colspan="3"></td>
									</tr>
									<tr>
										<td colspan="2">采血开始时间</td>
										<td colspan="3">{{queryItemInfo('RYPG-BLOOD-TIME').toString()}}</td>
										<td colspan="2">质控平车</td>
										<td colspan="3"></td>
									</tr>
									<tr>
										<td colspan="2">血样报告时间</td>
										<td colspan="3">{{queryItemInfo('RYPG-BLOOD-REPORT-TIME').toString()}}</td>
										<td colspan="2"></td>
										<td colspan="3"></td>
									</tr>
									<tr>
										<td colspan="2">心电开始时间</td>
										<td colspan="3">{{queryItemInfo('RYPG-ECG-TIME').toString()}}</td>
										<td colspan="2"></td>
										<td colspan="3"></td>
									</tr>
									<tr>
										<td colspan="2">到达CT时间</td>
										<td colspan="3">{{queryItemInfo('RYPG-CT-DD-TIME').toString()}}</td>
										<td colspan="2">质控平车</td>
										<td colspan="3"></td>
									</tr>
									<tr>
										<td colspan="2">CT检查开始时间</td>
										<td colspan="3">{{queryItemInfo('RYPG-CT-JCKS-TIME').toString()}}</td>
										<td colspan="2">质控平车</td>
										<td colspan="3"></td>
									</tr>
									<tr>
										<td colspan="2">CT检查完毕时间</td>
										<td colspan="3">{{queryItemInfo('RYPG-CT-JCWB-TIME').toString()}}</td>
										<td colspan="2"></td>
										<td colspan="3"></td>
									</tr>
									<!-- <tr>
										<td colspan="2">离开CT时间</td>
										<td colspan="3">{{queryItemInfo('RYPG-CT-LK-TIME').toString()}}</td>
										<td colspan="2"></td>
										<td colspan="3"></td>
									</tr> -->
									<tr>
										<td colspan="2">到达核磁时间</td>
										<td colspan="3">{{queryItemInfo('JMRS-HC-TIME').toString()}}</td>
										<td colspan="2"></td>
										<td colspan="3"></td>
									</tr>
									<tr>
										<td colspan="2">二线医生到场时间</td>
										<td colspan="3">{{queryItemInfo('JBXX-SNYSDC-TIME').toString()}}</td>
										<td colspan="2"></td>
										<td colspan="3"></td>
									</tr>
									<tr>
										<td colspan="2">谈话开始时间</td>
										<td colspan="3">{{queryItemInfo('JMRS-TH-TIME').toString()}}</td>
										<td colspan="2"></td>
										<td colspan="3"></td>
									</tr>
									<tr>
										<td colspan="2">签署知情同意书时间</td>
										<td colspan="3">{{queryItemInfo('JMRS-ZQTY-TIME').toString()}}</td>
										<td colspan="2"></td>
										<td colspan="3"></td>
									</tr>
									<tr>
										<td colspan="2">到达溶栓区时间</td>
										<td colspan="3">{{queryItemInfo('JMRS-RSQ-TIME').toString()}}</td>
										<td colspan="2"></td>
										<td colspan="3"></td>
									</tr>
									<tr>
										<td colspan="2">静脉溶栓开始时间</td>
										<td colspan="3">{{queryItemInfo('JMRS-TIME').toString()}}</td>
										<td colspan="2"></td>
										<td colspan="3"></td>
									</tr>
									<tr>
										<td colspan="2">静脉溶栓结束时间</td>
										<td colspan="3">{{queryItemInfo('JMRS-END-TIME').toString()}}</td>
										<td colspan="2"></td>
										<td colspan="3"></td>
									</tr>
									<tr>
										<td colspan="2">进入介入室时间</td>
										<td colspan="3">{{queryItemInfo('JMRS-DDJRS').toString()}}</td>
										<td colspan="2"></td>
										<td colspan="3"></td>
									</tr>
									<tr>
										<td colspan="2">置鞘时间</td>
										<td colspan="3">{{queryItemInfo('XGZL-CCWC-TIME').toString()}}</td>
										<td colspan="2"></td>
										<td colspan="3"></td>
									</tr>
									<tr>
										<td colspan="2">血管再通时间</td>
										<td colspan="3">{{queryItemInfo('XGZL-SH-SCXGZTSJ').toString()}}</td>
										<td colspan="2"></td>
										<td colspan="3"></td>
									</tr>
									<tr>
										<td colspan="2">进入病房时间</td>
										<td colspan="3">{{queryItemInfo('JMRS-DDBF').toString()}}</td>
										<td colspan="2"></td>
										<td colspan="3"></td>
									</tr>
								</table>
							</div>
						</div>
					</a-card>
				</a-col>
				<a-col :span="24">
					<a-card class="report-card" title="介入手术记录">
						<a slot="extra" href="javascript:;" @click="handleExportJrPdf">导出</a>
						<div class="doc-ct-content" style="min-height: 300px;">
							<div class="record-content" v-html="operaData"></div>
							<div class="emtpy" v-if="!operaData">
								<a-empty :image="emptyImage" description="暂无手术记录" />
							</div>
						</div>
					</a-card>
				</a-col>
			</a-row>
		</div>
		<div style="background-color: #fff;padding-bottom: 12px;border-top: 1px solid #eee;">
			<div class="throm-common-button" >
				<a-button :disabled="writeAble" class="" type="primary" size="large" block
					@click="handleExportAll">打印</a-button>
				<!-- <a-button :disabled="writeAble" class="" block type="primary" size="large"
					@click="onSubmit">导出</a-button> -->
			</div>
		</div>
		
		<throm-report-dnt ref="dnt"></throm-report-dnt>
		<throm-report-record ref="record"></throm-report-record>
		<throm-report-observe ref="observe"></throm-report-observe>
		<throm-report-opera ref="opera"></throm-report-opera>
		<a ref="downloadRef" target="_blank" href="javascript:;" style="display: none;"></a>
	</div>
</template>

<script>
	import {
		mapMutations,
		mapState
	} from 'vuex';
	import {
		apiUrl
	} from '@/config/setting.js';
	import {
		getNextNode,
		messageQuery,
		queryAidRecord,
		queryLog,
		operationLog,
		getCtInfoPath,
		operationLogEx,
		exportRsPdf,
		exportDntPdf,
		exportRsgcbPdf,
		exportJrPdf,
		exportAll,
	} from 'api';
	import dayjs from 'dayjs';
	import duration from 'dayjs/plugin/duration';
	import ThromReportDnt from './throm-report-dnt.vue';
	import ThromReportRecord from './throm-report-record.vue';
	import ThromReportObserve from './throm-report-observe.vue';
	import ThromReportOpera from './throm-report-opera.vue';
	import emptyImage from '@/assets/images/slice/empty.png'

	dayjs.extend(duration);
	export default {
		name: "throm-report",
		components: {
			ThromReportDnt,
			ThromReportRecord,
			ThromReportObserve,
			ThromReportOpera,
		},
		data() {
			return {
				emptyImage,
				currentIndex: 1,
				dataList: [{
						name: '急诊溶栓记录',
						type: 'record'
					},
					{
						name: '溶栓观察表',
						type: 'observe'
					},
					{
						name: 'DNT时间表',
						type: 'dnt'
					},
					{
						name: '介入手术记录',
						type: 'opera'
					},
				],
				nodeInfo: {
					fbsj: '',
					jfbSeconds: '',
					dntSeconds: '',
					ctSeconds: '',
					nextStepName: '',
					countDownInSeconds: '',
					nodeList: [],
				},
				dataInfo: {
					patientAge: '',
					patientIdCardNo: '',
					patientGender: '',
					patientName: '',
				},
				codeForm: {
					'RYPG-HEIGHT': '',
					'RYPG-WEIGHT': '',
					'RYPG-BMI': '',
					'RYPG-PULSE': '',
					'RYPG-SYSTOLIC-PRESSURE': '',
					'RYPG-DIASTOLIC-PRESSURE': '',
					'RYPG-MRS': '',
					'RYPG-NIHSS': '',
				},
				request: 1,
				processNodeIndex: 0,
				patient: {},
				recordData: "",
				observeData: "",
				dntData: "",
				operaData: "",
			}
		},
		props: {
			reportType: {
				type: String,
				default: "",
			},
			dataSource: {
				type: Object,
				default: () => ({})
			},
			firstAidId: {
				type: String,
				default: "",
			}
		},
		computed: {
			...mapState('patient', ['patientData', 'nextNodeData', 'writeAble']),
			getPatient() {
				const {
					firstAidId,
					patientName,
					patientGender,
					patientAge
				} = this.patient;
				if (!firstAidId) return;
				return `${patientName}  ${ patientGender === 0 ? '男' : patientGender === 1 ? '女' : '' }  ${patientAge || ''}`;
			},
			getPressure() {
				const {
					codeForm
				} = this;
				let result;
				if (
					codeForm['RYPG-SYSTOLIC-PRESSURE'] &&
					codeForm['RYPG-DIASTOLIC-PRESSURE']
				) {
					result = `${codeForm['RYPG-SYSTOLIC-PRESSURE']}/${codeForm['RYPG-DIASTOLIC-PRESSURE']}mmHg`;
				} else if (codeForm['RYPG-SYSTOLIC-PRESSURE']) {
					result = `${codeForm['RYPG-SYSTOLIC-PRESSURE']}mmHg`;
				} else {
					result = '暂无';
				}
				return result;
			},
			getNodeList() {
				const {
					sop
				} = this.nodeInfo;
				if (!sop) return [];
				const lastFinishIndex = sop.nodeList.findIndex(a => !!a.record) || 0
				this.processNodeIndex = lastFinishIndex + 1
				return sop.nodeList;
			},
			getFirstInfo() {
				const {
					recordValDict
				} = this.patient
				if (!recordValDict) return {}
				else return {
					'RYPG-WEIGHT': recordValDict['RYPG-WEIGHT']?.[0].answer[0], // 身高
					'RYPG-HEIGHT': recordValDict['RYPG-HEIGHT']?.[0].answer[0], // 体重
					'RYPG-MRS': recordValDict['RYPG-MRS']?.[0].answer[0], // MRS评分
					'RYPG-NIHSS': recordValDict['RYPG-NIHSS']?.[0].answer[0], // NIHSS评分
					'RYPG-BMI': recordValDict['RYPG-BMI']?.[0].answer[0], // BMI
					'RYPG-SYSTOLIC-PRESSURE': recordValDict['RYPG-SYSTOLIC-PRESSURE']?.[0].answer[0], // 收缩压
					'RYPG-DIASTOLIC-PRESSURE': recordValDict['RYPG-DIASTOLIC-PRESSURE']?.[0].answer[0], // 舒张压
					'RYPG-BLOOD-SUGAR': recordValDict['RYPG-BLOOD-SUGAR']?.[0].answer[0], //血糖
					'RYPG-PULSE': recordValDict['RYPG-PULSE']?.[0].answer[0], // 脉搏
					'JMRS-RSYW': recordValDict['JMRS-RSYW']?.[0].answer[0], // 溶栓药物
					'JMRS-JDJL': recordValDict['JMRS-JDJL']?.[0].answer[0], // 静滴剂量
					'JMRS-TZJL': recordValDict['JMRS-TZJL']?.[0].answer[0], // 团注剂量
				}
			}
		},
		async mounted() {
			//TODU
			if (this.reportType == 'modal') {
				console.log(this.dataSource)
				// this.patient = this.dataSource
				this.init(this.dataSource.firstAidId);
			} else {
				// if (!this.patientData) return;
				// this.patient = this.patientData
				if (this.firstAidId) {
					this.init(this.firstAidId);
					await this.getMessageQuery(this.firstAidId);
				}
			}
			// const {
			// 	firstAidId
			// } = this.patient;
			console.log('report firstAidId', this.firstAidId)

		},
		methods: {
			...mapMutations('patient', ['setNextNodeData', 'setTimerData']),
			async getMessageQuery(firstAidId) {
				// const {
				// 	firstAidId
				// } = this.patientData;
				const res = await messageQuery(firstAidId);
				const {
					code,
					msg
				} = res;
				if (code === 200) {
					this.setTimerData(res.data);
				}
			},
			queryItemInfo(type) {
				const dict = this.patient?.recordValDict?.[type]
				if (dict) {
					return dict[0].answer
				} else {
					return '-'
				}
			},
			onSubmit() {
				// this.$emit('next')
			},
			async getData(firstAidId) {
				const resLog = await queryLog({
					firstAidId
				})
				this.recordData = resLog.data || ''


				// const resObserve = await getCtInfoPath({
				// 	firstAidId
				// })
				// this.observeData = resObserve.data || []

				const resOperaLog = await operationLog({
					firstAidId
				})
				this.observeData = resOperaLog.data || ''
				this.operaData = resOperaLog.data || ''

				// const res = await operationLogEx({
				// 	firstAidId
				// })
			},
			getHMS(time) {
				if (!time) return;
				// ?️ 获取完整分钟数
				const minutes = Math.floor(Number(time) / 60);

				// ?️ 获得剩余的秒数
				const seconds = Number(time) % 60;
				// ✅ 格式化为 MM:SS
				let result = `${this.padTo2Digits(minutes)}'${this.padTo2Digits(
					seconds
				)}''`;
				console.log('minutes: ', minutes);
				if (minutes / 60 > 4.5) {
					result = '>4.5h';
				}
				return result;
			},
			padTo2Digits(num) {
				return num.toString().padStart(2, '0');
			},
			//溶栓记录
			toRecord() {
				this.$router.push({
					name: 'Record',
				});
			},
			async handleExport() {
				console.log('this.patient.firstAidId', this.patient.firstAidId)
				const res = await exportRsPdf({
					firstAidId: this.patient.firstAidId
				})
				if (res.code == 200) {
					console.log('http://116.204.114.73:20007' + res.data)
					this.$refs.downloadRef.setAttribute('href', 'http://116.204.114.73:20007' + res.data)
					this.$refs.downloadRef.click()
				}

			},
			checkReport(modalRef) {
				console.log('modalRef', this.patient)
				// const {
				// 	sourceId,
				// 	patientName,
				// 	patientAge,
				// 	patientGender,
				// 	firstAidId,
				// } = this.patient;
				// this.setPatientData({
				// 	sourceId,
				// 	patientName,
				// 	patientAge,
				// 	patientGender,
				// 	firstAidId,
				// });
				this.$refs[modalRef].open(this.patient)
			},
			//回显数据
			echo(data) {
				for (let k in data) {
					if (data[k]) {
						const {
							answer
						} = data[k][0];
						this.codeForm[k] = answer.toString();
						if (k === 'RYPG-WEIGHT' || k === 'RYPG-HEIGHT') {
							this.codeForm['RYPG-BMI'] = this.utils.computeBMI(
								this.codeForm['RYPG-WEIGHT'],
								this.codeForm['RYPG-HEIGHT']
							);
						}
					}
				}
			},
			//初始化数据
			async init(firstAidId) {

				const res = await queryAidRecord(firstAidId)
				console.log(res)
				this.patient = res.data
				// if (this.patientData) {
				// 	const {
				// 		recordValDict
				// 	} = this.patientData;
				// 	let data = Object.assign({}, this.patientData);
				// 	this.utils.merge(this.dataInfo, data);
				// 	if (recordValDict) {
				// 		this.echo(recordValDict);
				// 	}
				// }
				// const {
				// 	firstAidId
				// } = this.patientData;
				this.getNextNode(firstAidId);
				this.getData(firstAidId)
			},
			async getNextNode(firstAidId) {
				let res = await getNextNode({
					firstAidId,
				});
				const {
					data,
					code,
					msg
				} = res;
				if (code === 200) {
					console.log('this.nodeInfo', data)
					this.nodeInfo = data;
					this.setNextNodeData(data);
				} else {
					this.$message.error('缺少急救id信息');
				}
			},

			async handleExportRsPdf() {
				const {
					firstAidId
				} = this.patient
				const res = await exportRsPdf({
					firstAidId
				})
				const {
					code,
					data,
					msg
				} = res
				if (code === 200) {
					this.toDownLoad(data)
				} else {
					this.$message.error(msg)
				}
			},
			async handleExportDntPdf() {
				const {
					firstAidId
				} = this.patient
				const res = await exportDntPdf({
					firstAidId
				})
				const {
					code,
					data,
					msg
				} = res
				if (code === 200) {
					this.toDownLoad(data)
				} else {
					this.$message.error(msg)
				}
			},
			async handleExportRsgcbPdf() {
				const {
					firstAidId
				} = this.patient
				const res = await exportRsgcbPdf({
					firstAidId
				})
				const {
					code,
					data,
					msg
				} = res
				if (code === 200) {
					this.toDownLoad(data)
				} else {
					this.$message.error(msg)
				}
			},
			async handleExportJrPdf() {
				const {
					firstAidId
				} = this.patient
				const res = await exportJrPdf({
					firstAidId
				})
				const {
					code,
					data,
					msg
				} = res
				if (code === 200) {
					this.toDownLoad(data)
				} else {
					this.$message.error(msg)
				}
			},
			async handleExportAll() {
				const {
					firstAidId
				} = this.patient
				const res = await exportAll({
					firstAidId
				})
				const {
					code,
					data,
					msg
				} = res
				if (code === 200) {
					this.toDownLoad(data)
				} else {
					this.$message.error(msg)
				}
			},
			toDownLoad(path) {
				try {
					// document.getElementById('exportFirst').href = path;
					// document.getElementById('exportFirst').download = '.xlsx';

					this.$refs.downloadRef.setAttribute('href', 'http://116.204.114.73:20007' + path)
					this.$refs.downloadRef.setAttribute('download', '.xlsx')
					this.$refs.downloadRef.click()
				} catch (e) {
					//TODO handle the exception
					console.log(e.message)
				}
			}
		}
	}
</script>

<style lang="less" scoped>
	.throm-report {
		.report-container {
			height: calc(100vh - 196px);
			overflow-y: auto;
			overflow-x: hidden;
		}

		.report-card {
			box-sizing: border-box;
			font-size: 1rem;

			.report-patient-box {
				.report-patient-info {
					display: flex;

					.report-patient-avatar {
						width: 60px;
						height: 60px;
						border-radius: 60px;
						border: 2px solid #eee;
						overflow: hidden;
						margin-right: 2rem;

						img {
							width: 100%;
							height: 100%;
						}
					}

					.report-patient-name {
						flex: 1;
						display: flex;
						flex-direction: column;
						line-height: 30px;
						padding: 5px 0;

						.report-pname {
							font-size: 1.2rem;
							font-weight: bold;
						}

						.reort-psan {
							.reort-psex {
								margin-right: 1rem;
							}

							.reort-page {
								margin-right: 1rem;
							}

							.reort-pnat {}
						}
					}
				}

				.report-patient-tags {
					display: flex;
					margin-top: 1rem;

					.report-patient-tag {
						border-radius: 6px;
						background-color: #B3E5FF;
						color: #007AFF;
						padding: 6px 12px;
						margin-right: 10px;
					}
				}

				.report-patient-row {
					margin: .5rem 0;

					.report-patient-rowlabel {
						color: #666666;
					}

					.report-patient-rowtext {
						color: #000000;
					}
				}
			}

			.report-treat-box {
				.report-treat-row1 {
					margin: .2rem 0;
					font-size: 1rem;
					font-weight: bold;

					.report-treat-rowlabel {
						color: #000000;
						margin-right: .5rem;
					}

					.report-treat-rowtext {
						color: #007AFF;
					}
				}

				.report-treat-row2 {
					margin: .2rem 0;

					.report-treat-rowlabel {
						color: #666666;
					}

					.report-treat-rowtext {
						color: #000000;
						margin-right: 12px;
					}
				}

			}

			.report-rsgcb {
				width: 100%;

				td {
					padding: 12px;
				}
			}


		}
	}
</style>
<style lang="less">
	.throm-report {
		.ant-list-item {
			padding: 12px 20px;
		}

		.ant-card-body {
			padding: 20px;
		}

		.report-timeline {
			overflow-y: auto;
			.ant-steps {
				height: 100%;
				padding-bottom: 20px;
				box-sizing: border-box;
				display: flex;
				flex-direction: column;
			}

			.ant-steps-item-title {
				padding: 0;
				width: 100%;
			}

			.ant-steps-item-finish {
				.ant-steps-item-title {
					color: #000000;
				}
			}

			.ant-steps-item-process {
				.ant-steps-item-title {
					color: #007AFF;
					// 	// border-bottom: 1px solid #007AFF;
					// 	border-bottom: 3px solid transparent;
					// 	/* 设置透明的底部边框 */
					// 	border-image: linear-gradient(to right, #fff, #007AFF) 1;
					// 	/* 使用渐变色填充边框 */
					// 	border-radius: 10px;
					// 	/* 设置圆角 */
				}
			}
		}
		
		.ant-card-bordered {
				border: none;
		
				.ant-card-head {
					border-bottom: none;
				}
			}
			.baseInfo{
				line-height:32px;
				.ant-col-8{
					padding-left:30px;
					padding-right:30px;
				}
				.leftTitle{
					float:left;
					font-size:18px;
					color:#888888; 
				}
				.rightValue{
					float:right;
					font-size:18px;
					color:#222; 
				}
		
				.midItem{
					border-left:1px solid #eee;
					border-right:1px solid #eee;
				}
			}
		.report-rsgcb td{
			font-size:18px;
			color:#3D3D3D;
		}
	}
	
</style>