提交merge1.3
This commit is contained in:
@@ -33,11 +33,7 @@
|
||||
"top": 22.5,
|
||||
"height": 12,
|
||||
"width": 88.5,
|
||||
<<<<<<< HEAD
|
||||
"title": "长春大学医院",
|
||||
=======
|
||||
"title": "长春市朝阳区中医院医院",
|
||||
>>>>>>> v1.3
|
||||
"coordinateSync": false,
|
||||
"widthHeightSync": false,
|
||||
"fontSize": 13.5,
|
||||
@@ -335,8 +331,4 @@
|
||||
]
|
||||
}
|
||||
]
|
||||
<<<<<<< HEAD
|
||||
}
|
||||
=======
|
||||
}
|
||||
>>>>>>> v1.3
|
||||
|
||||
@@ -37,11 +37,7 @@
|
||||
"top": 16.5,
|
||||
"height": 22.5,
|
||||
"width": 120,
|
||||
<<<<<<< HEAD
|
||||
"title": "长春大学医院",
|
||||
=======
|
||||
"title": "长春市朝阳区中医院医院",
|
||||
>>>>>>> v1.3
|
||||
"coordinateSync": false,
|
||||
"widthHeightSync": false,
|
||||
"fontFamily": "Microsoft YaHei",
|
||||
|
||||
@@ -237,21 +237,6 @@
|
||||
ref="tableRef"
|
||||
>
|
||||
<el-table-column type="selection" width="55" align="center" fixed="left" />
|
||||
<<<<<<< HEAD
|
||||
<el-table-column
|
||||
prop="prescriptionNo"
|
||||
label="处方号"
|
||||
width="120"
|
||||
align="center"
|
||||
/>
|
||||
<el-table-column prop="itemName" label="项目名称" width="160" align="center" />
|
||||
<el-table-column
|
||||
prop="statusEnum_enumText"
|
||||
label="发药状态"
|
||||
width="100"
|
||||
align="center"
|
||||
>
|
||||
=======
|
||||
<el-table-column prop="prescriptionNo" label="处方号" width="120" align="center" />
|
||||
<el-table-column prop="conditionName" label="诊断" width="120" align="center" />
|
||||
<el-table-column prop="medTypeCode_dictText" label="处方类型" width="120" align="center" />
|
||||
@@ -317,7 +302,6 @@
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="statusEnum_enumText" label="发药状态" width="100" align="center">
|
||||
>>>>>>> v1.3
|
||||
<template #default="scope">
|
||||
<el-tag :type="tagType(scope.row.statusEnum)">
|
||||
{{ scope.row.statusEnum_enumText }}
|
||||
@@ -380,22 +364,7 @@
|
||||
<el-table-column prop="doctorName" label="开单医生" width="100" align="center" />
|
||||
<!-- <el-table-column prop="dose" label="剂量" width="100" align="center" /> -->
|
||||
<el-table-column prop="rateCode" label="频次" width="100" align="center" />
|
||||
<<<<<<< HEAD
|
||||
<el-table-column
|
||||
prop="methodCode_dictText"
|
||||
label="用法"
|
||||
width="100"
|
||||
align="center"
|
||||
/>
|
||||
<el-table-column
|
||||
prop="dispensePerDuration"
|
||||
label="天数"
|
||||
width="80"
|
||||
align="center"
|
||||
/>
|
||||
=======
|
||||
<el-table-column prop="methodCode_dictText" label="用法" width="100" align="center" />
|
||||
>>>>>>> v1.3
|
||||
<el-table-column
|
||||
label="操作"
|
||||
align="center"
|
||||
@@ -473,13 +442,8 @@
|
||||
</template>
|
||||
|
||||
<script setup name="westernmedicine">
|
||||
<<<<<<< HEAD
|
||||
import { ref, computed, onMounted, onBeforeMount } from "vue";
|
||||
import { ElMessage } from "element-plus";
|
||||
=======
|
||||
import { ref, computed, onMounted, onBeforeMount, nextTick } from 'vue';
|
||||
import { ElMessage } from 'element-plus';
|
||||
>>>>>>> v1.3
|
||||
import {
|
||||
listWesternmedicine,
|
||||
listPatient,
|
||||
@@ -492,16 +456,6 @@ import {
|
||||
deviceDispense,
|
||||
deviceInvalid,
|
||||
devicePatientList,
|
||||
<<<<<<< HEAD
|
||||
} from "./components/api";
|
||||
import { advicePrint } from "@/api/public";
|
||||
import { formatDate, formatDateStr } from "@/utils/index";
|
||||
import { debounce } from "lodash-es";
|
||||
import TraceNoDialog from "@/components/OpenHis/TraceNoDialog/index.vue";
|
||||
// 使用window.hiprint,不再从vue-plugin-hiprint导入
|
||||
import templateJson from "./components/templateJson.json";
|
||||
import disposalTemplate from "./components/disposalTemplate.json";
|
||||
=======
|
||||
medicineMatch,
|
||||
getDoctorSignature,
|
||||
} from './components/api';
|
||||
@@ -515,7 +469,6 @@ import templateJson from '@/components/Print/Pharmacy.json';
|
||||
import chineseMedicineTemplateJson from '@/components/Print/ChineseMedicinePrescription.json';
|
||||
import disposalTemplate from './components/disposalTemplate.json';
|
||||
import { formatInventory } from '../../../utils/his';
|
||||
>>>>>>> v1.3
|
||||
|
||||
const { proxy } = getCurrentInstance();
|
||||
const showSearch = ref(true);
|
||||
@@ -550,13 +503,9 @@ const isManualSelection = ref(false);
|
||||
const couldSave = ref(true);
|
||||
const groups = ref({});
|
||||
const openTraceNoDialog = ref(false);
|
||||
<<<<<<< HEAD
|
||||
const ypName = ref("");
|
||||
=======
|
||||
const loading = ref(false);
|
||||
const adjustPriceSwitchState = ref(false);
|
||||
const ypName = ref('');
|
||||
>>>>>>> v1.3
|
||||
const medicineTotalPrice = ref(0);
|
||||
const projectTypeCode = ref("2");
|
||||
const selectedRow = ref(null);
|
||||
@@ -619,76 +568,21 @@ function submit(value) {
|
||||
}
|
||||
});
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
// 设置默认日期范围为当天
|
||||
function setDefaultDateRange() {
|
||||
const today = new Date();
|
||||
const year = today.getFullYear();
|
||||
const month = String(today.getMonth() + 1).padStart(2, "0");
|
||||
const day = String(today.getDate()).padStart(2, "0");
|
||||
const formattedDate = `${year}-${month}-${day}`;
|
||||
dateRange.value = [formattedDate, formattedDate];
|
||||
console.log("222", dateRange.value);
|
||||
}
|
||||
|
||||
function getList() {
|
||||
console.log("224555552", dateRange.value);
|
||||
queryParams.value.receptionTimeSTime = dateRange.value[0] + " 00:00:00";
|
||||
queryParams.value.receptionTimeETime = dateRange.value[1] + " 23:59:59";
|
||||
|
||||
console.log("222", queryParams.value);
|
||||
if (projectTypeCode.value == 2) {
|
||||
listPatient(queryParams.value).then((response) => {
|
||||
console.log("Full response1:", response);
|
||||
=======
|
||||
|
||||
function getList() {
|
||||
queryParams.value.receptionTimeSTime = dateRange.value[0] + ' 00:00:00';
|
||||
queryParams.value.receptionTimeETime = dateRange.value[1] + ' 23:59:59';
|
||||
if (projectTypeCode.value == 2) {
|
||||
listPatient(queryParams.value).then((response) => {
|
||||
>>>>>>> v1.3
|
||||
patientList.value = response.data.records;
|
||||
total.value = response.data.total;
|
||||
});
|
||||
} else if (projectTypeCode.value == 3) {
|
||||
<<<<<<< HEAD
|
||||
debugger;
|
||||
devicePatientList(queryParams.value).then((response) => {
|
||||
console.log("Full response1:", response);
|
||||
=======
|
||||
devicePatientList(queryParams.value).then((response) => {
|
||||
>>>>>>> v1.3
|
||||
patientList.value = response.data.records;
|
||||
total.value = response.data.total;
|
||||
});
|
||||
} else {
|
||||
<<<<<<< HEAD
|
||||
Promise.all([
|
||||
listPatient(queryParams.value),
|
||||
devicePatientList(queryParams.value),
|
||||
]).then(([patientRes, deviceRes]) => {
|
||||
// 合并两个接口的数据
|
||||
const patientRecords = patientRes.data.records || [];
|
||||
const deviceRecords = deviceRes.data.records || [];
|
||||
const combinedRecords = [...patientRecords, ...deviceRecords];
|
||||
// 根据 encounterId 去重
|
||||
const uniqueRecords = combinedRecords.filter(
|
||||
(item, index, self) =>
|
||||
index === self.findIndex((record) => record.encounterId === item.encounterId)
|
||||
);
|
||||
patientList.value = uniqueRecords;
|
||||
// 合并总数量(如果需要精确数量,可能需要后端支持)
|
||||
total.value = uniqueRecords.length;
|
||||
});
|
||||
}
|
||||
listInit().then((response) => {
|
||||
console.log("Full response2:", response);
|
||||
departmentList.value = [
|
||||
{ value: null, label: "全部" },
|
||||
...response.data.departmentOptions,
|
||||
];
|
||||
=======
|
||||
Promise.all([listPatient(queryParams.value), devicePatientList(queryParams.value)]).then(
|
||||
([patientRes, deviceRes]) => {
|
||||
// 合并两个接口的数据
|
||||
@@ -708,18 +602,12 @@ function getList() {
|
||||
}
|
||||
listInit().then((response) => {
|
||||
departmentList.value = [{ value: null, label: '全部' }, ...response.data.departmentOptions];
|
||||
>>>>>>> v1.3
|
||||
backReason.value = response.data.notPerformedReasonOptions;
|
||||
dispenseStatusOptions.value = response.data.dispenseStatusOptions;
|
||||
preparerDoctorOptions.value = response.data.preparerDoctorOptions;
|
||||
preparerDoctor.value = preparerDoctorOptions.value[0].value;
|
||||
});
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
//打印中西药处方
|
||||
=======
|
||||
|
||||
>>>>>>> v1.3
|
||||
async function printPrescription() {
|
||||
const selectedRows = tableRef.value.getSelectionRows();
|
||||
if (selectedRows.length === 0) {
|
||||
@@ -739,543 +627,6 @@ async function printPrescription() {
|
||||
groupedRows[prescriptionNo].push(row);
|
||||
});
|
||||
|
||||
<<<<<<< HEAD
|
||||
console.log("按处方号分组的结果:", groupedRows);
|
||||
|
||||
// 如果您需要将分组后的数据转换为数组形式
|
||||
const groupedArray = Object.values(groupedRows);
|
||||
console.log("分组后的数组形式:", groupedArray);
|
||||
|
||||
groupedArray.forEach((item, index) => {
|
||||
const total = item.reduce((sum, item) => {
|
||||
return sum + (item.totalPrice || 0);
|
||||
}, 0);
|
||||
result.push({
|
||||
...res.data,
|
||||
medTotalAmount: total,
|
||||
prescriptionList: item,
|
||||
});
|
||||
});
|
||||
console.log(result, "result");
|
||||
const printElements = templateJson;
|
||||
var hiprintTemplate = new hiprint.PrintTemplate({ template: printElements }); // 定义模板
|
||||
hiprintTemplate.print2(result, {
|
||||
title: "打印标题",
|
||||
height: 210,
|
||||
width: 148,
|
||||
}); //开始打印
|
||||
// 直接打印回调
|
||||
// 发送任务到打印机成功
|
||||
hiprintTemplate.on("printSuccess", function (e) {
|
||||
console.log("打印成功");
|
||||
});
|
||||
// 发送任务到打印机失败
|
||||
hiprintTemplate.on("printError", function (e) {
|
||||
console.log("打印失败");
|
||||
});
|
||||
});
|
||||
}
|
||||
// 新增打印机相关变量
|
||||
const printerList = ref([]); // 打印机列表
|
||||
const selectedPrinter = ref(""); // 选中的打印机
|
||||
const showPrinterDialog = ref(false); // 显示打印机选择对话框
|
||||
const previewData = ref(null); // 预览数据
|
||||
|
||||
// 抽取获取打印数据的公共函数
|
||||
// 合并预览和打印功能的主函数
|
||||
async function previewAndPrint() {
|
||||
try {
|
||||
const result = await getPrintData();
|
||||
if (!result) return;
|
||||
|
||||
// 保存预览数据
|
||||
previewData.value = result;
|
||||
|
||||
console.log("直接执行处方打印预览");
|
||||
|
||||
// 构建预览HTML(保持原有格式)
|
||||
let previewHtml = "";
|
||||
|
||||
// 为每个处方生成预览内容
|
||||
result.forEach((prescription, index) => {
|
||||
// 确保处方数据存在
|
||||
if (!prescription) return;
|
||||
|
||||
// 从处方获取药品列表,确保是数组
|
||||
const prescriptionList = Array.isArray(prescription.prescriptionList)
|
||||
? prescription.prescriptionList
|
||||
: [];
|
||||
|
||||
previewHtml += '<div class="prescription-container">';
|
||||
previewHtml += "<h3>处方 " + (index + 1) + "</h3>";
|
||||
previewHtml += '<div class="prescription-info">';
|
||||
previewHtml +=
|
||||
"<p><strong>处方号:</strong> " + (prescription.prescriptionNo || "N/A") + "</p>";
|
||||
previewHtml +=
|
||||
"<p><strong>患者姓名:</strong> " + (prescription.patientName || "N/A") + "</p>";
|
||||
previewHtml +=
|
||||
"<p><strong>性别:</strong> " +
|
||||
(prescription.genderEnum_enumText || prescription.gender || "N/A") +
|
||||
"</p>";
|
||||
previewHtml += "<p><strong>年龄:</strong> " + (prescription.age || "N/A") + "</p>";
|
||||
previewHtml +=
|
||||
"<p><strong>开具日期:</strong> " +
|
||||
(prescription.reqTime ||
|
||||
prescription.adviceDate ||
|
||||
prescription.createTime ||
|
||||
new Date().toLocaleDateString()) +
|
||||
"</p>";
|
||||
previewHtml +=
|
||||
"<p><strong>医生:</strong> " + (prescription.doctorName || "N/A") + "</p>";
|
||||
|
||||
// 添加额外的处方信息
|
||||
if (prescription.encounterNo)
|
||||
previewHtml += "<p><strong>门诊号:</strong> " + prescription.encounterNo + "</p>";
|
||||
if (prescription.departmentName)
|
||||
previewHtml +=
|
||||
"<p><strong>科室:</strong> " + prescription.departmentName + "</p>";
|
||||
if (prescription.conditionName)
|
||||
previewHtml +=
|
||||
"<p><strong>临床诊断:</strong> " + prescription.conditionName + "</p>";
|
||||
if (prescription.phone)
|
||||
previewHtml += "<p><strong>电话:</strong> " + prescription.phone + "</p>";
|
||||
previewHtml += "</div>";
|
||||
|
||||
previewHtml += '<table class="prescription-table">';
|
||||
previewHtml += "<thead>";
|
||||
previewHtml += "<tr>";
|
||||
previewHtml += "<th>药品名称</th>";
|
||||
previewHtml += "<th>规格</th>";
|
||||
previewHtml += "<th>单价</th>";
|
||||
previewHtml += "<th>数量</th>";
|
||||
previewHtml += "<th>金额</th>";
|
||||
previewHtml += "<th>费用等级</th>";
|
||||
previewHtml += "<th>用法用量</th>";
|
||||
previewHtml += "</tr>";
|
||||
previewHtml += "</thead>";
|
||||
previewHtml += "<tbody>";
|
||||
|
||||
// 添加药品列表
|
||||
if (prescriptionList.length > 0) {
|
||||
prescriptionList.forEach((item) => {
|
||||
previewHtml += "<tr>";
|
||||
// 使用映射后的字段名,确保与打印模板一致
|
||||
previewHtml += "<td>" + (item.medicineName || item.itemName || "N/A") + "</td>";
|
||||
previewHtml += "<td>" + (item.totalVolume || item.spec || "") + "</td>";
|
||||
previewHtml += "<td>" + (item.unitPrice || item.price || "0.00") + "</td>";
|
||||
previewHtml +=
|
||||
"<td>" +
|
||||
(item.quantity || "N/A") +
|
||||
" " +
|
||||
(item.unitCode_dictText || item.unit || "") +
|
||||
"</td>";
|
||||
previewHtml += "<td>" + (item.totalPrice || "0.00") + "</td>";
|
||||
previewHtml += "<td>" + (item.contractName || "N/A") + "</td>";
|
||||
|
||||
// 组合用法用量信息
|
||||
const usageInfo = [];
|
||||
if (item.dose && item.doseUnitCode_dictText) {
|
||||
usageInfo.push(item.dose + item.doseUnitCode_dictText);
|
||||
}
|
||||
if (item.methodCode_dictText || item.usage) {
|
||||
usageInfo.push(item.methodCode_dictText || item.usage);
|
||||
}
|
||||
if (item.frequency) {
|
||||
usageInfo.push(item.frequency);
|
||||
}
|
||||
previewHtml += "<td>" + usageInfo.join("<br/>") + "</td>";
|
||||
previewHtml += "</tr>";
|
||||
});
|
||||
} else {
|
||||
previewHtml +=
|
||||
'<tr><td colspan="7" style="text-align: center;">暂无药品信息</td></tr>';
|
||||
}
|
||||
|
||||
previewHtml += "</tbody>";
|
||||
previewHtml += "<tfoot>";
|
||||
previewHtml += "<tr>";
|
||||
previewHtml +=
|
||||
'<td colspan="6" style="text-align: right; font-weight: bold;">总计:</td>';
|
||||
previewHtml +=
|
||||
'<td style="font-weight: bold;">' +
|
||||
(prescription.medTotalAmount || "0.00") +
|
||||
"</td>";
|
||||
previewHtml += "</tr>";
|
||||
previewHtml += "</tfoot>";
|
||||
previewHtml += "</table>";
|
||||
|
||||
previewHtml += '<div class="prescription-footer">';
|
||||
previewHtml +=
|
||||
"<p><strong>医疗机构:</strong> " + (prescription.contractName || "N/A") + "</p>";
|
||||
previewHtml += "</div>";
|
||||
previewHtml += "</div>";
|
||||
previewHtml += '<hr class="prescription-separator">';
|
||||
}); // ✅ 正确的 forEach 结束位置
|
||||
|
||||
// ✅ hiprint 打印逻辑移到这里(forEach 循环之外)
|
||||
console.log(result, "result");
|
||||
const printElements = templateJson;
|
||||
var hiprintTemplate = new hiprint.PrintTemplate({ template: printElements });
|
||||
hiprintTemplate.print2(result, {
|
||||
height: 210,
|
||||
width: 148,
|
||||
});
|
||||
|
||||
// 打印回调
|
||||
hiprintTemplate.on("printSuccess", function (e) {
|
||||
console.log("打印成功");
|
||||
});
|
||||
|
||||
hiprintTemplate.on("printError", function (e) {
|
||||
console.log("打印失败");
|
||||
});
|
||||
|
||||
// ✅ 创建临时打印容器(不可见)
|
||||
const printContainer = document.createElement("div");
|
||||
printContainer.style.position = "fixed";
|
||||
printContainer.style.left = "-9999px";
|
||||
printContainer.style.top = "-9999px";
|
||||
printContainer.style.width = "800px";
|
||||
|
||||
// 添加打印样式
|
||||
const style = document.createElement("style");
|
||||
style.textContent = `
|
||||
.print-content {
|
||||
font-family: Arial, sans-serif;
|
||||
font-size: 12px;
|
||||
}
|
||||
.patient-info-table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
.patient-info-table td {
|
||||
padding: 4px 8px;
|
||||
border: 1px solid #ddd;
|
||||
font-size: 12px;
|
||||
}
|
||||
.patient-info-table .label {
|
||||
font-weight: bold;
|
||||
background-color: #f9f9f9;
|
||||
}
|
||||
.medicine-table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
.medicine-table th,
|
||||
.medicine-table td {
|
||||
border: 1px solid #000;
|
||||
padding: 8px;
|
||||
text-align: left;
|
||||
}
|
||||
.medicine-table th {
|
||||
background: #f2f2f2;
|
||||
font-weight: bold;
|
||||
}
|
||||
.page-break {
|
||||
page-break-after: always;
|
||||
}
|
||||
@media print {
|
||||
body > *:not(#print-container) {
|
||||
display: none !important;
|
||||
}
|
||||
#print-container {
|
||||
position: static !important;
|
||||
width: 100% !important;
|
||||
}
|
||||
}
|
||||
`;
|
||||
document.head.appendChild(style);
|
||||
|
||||
printContainer.id = "print-container";
|
||||
|
||||
// 构建包含患者信息和药品信息的打印内容
|
||||
let printHtml = '<div class="print-content">';
|
||||
|
||||
result.forEach((prescription, index) => {
|
||||
if (!prescription) return;
|
||||
const prescriptionList = Array.isArray(prescription.prescriptionList)
|
||||
? prescription.prescriptionList
|
||||
: [];
|
||||
|
||||
printHtml += '<div class="prescription-medicines">';
|
||||
printHtml += "<h4>处方 " + (index + 1) + "</h4>";
|
||||
|
||||
// 添加患者信息表格
|
||||
printHtml += '<table class="patient-info-table">';
|
||||
printHtml += "<tr>";
|
||||
printHtml += '<td class="label">姓名:</td>';
|
||||
printHtml += "<td>" + (prescription.patientName || "-") + "</td>";
|
||||
printHtml += '<td class="label">性别:</td>';
|
||||
printHtml +=
|
||||
"<td>" +
|
||||
(prescription.genderEnum_enumText || prescription.gender || "-") +
|
||||
"</td>";
|
||||
printHtml += '<td class="label">年龄:</td>';
|
||||
printHtml += "<td>" + (prescription.age || "-") + "</td>";
|
||||
printHtml += '<td class="label">处方号:</td>';
|
||||
printHtml += "<td>" + (prescription.prescriptionNo || "-") + "</td>";
|
||||
printHtml += "</tr>";
|
||||
printHtml += "<tr>";
|
||||
printHtml += '<td class="label">门诊号:</td>';
|
||||
printHtml += "<td>" + (prescription.encounterNo || "-") + "</td>";
|
||||
printHtml += '<td class="label">开具日期:</td>';
|
||||
printHtml +=
|
||||
"<td>" +
|
||||
(prescription.reqTime ||
|
||||
prescription.adviceDate ||
|
||||
prescription.createTime ||
|
||||
"-") +
|
||||
"</td>";
|
||||
printHtml += '<td class="label">医生:</td>';
|
||||
printHtml += "<td>" + (prescription.doctorName || "-") + "</td>";
|
||||
printHtml += '<td class="label">科室:</td>';
|
||||
printHtml += "<td>" + (prescription.departmentName || "-") + "</td>";
|
||||
printHtml += "</tr>";
|
||||
printHtml += "<tr>";
|
||||
printHtml += '<td class="label">临床诊断:</td>';
|
||||
printHtml += '<td colspan="3">' + (prescription.conditionName || "-") + "</td>";
|
||||
printHtml += '<td class="label">电话:</td>';
|
||||
printHtml +=
|
||||
'<td colspan="3">' +
|
||||
(prescription.phone || prescription.mobile || prescription.patientPhone || "-") +
|
||||
"</td>";
|
||||
printHtml += "</tr>";
|
||||
printHtml += "</table>";
|
||||
|
||||
// 添加药品信息表格
|
||||
if (prescriptionList.length > 0) {
|
||||
printHtml += '<table class="medicine-table">';
|
||||
printHtml += "<thead>";
|
||||
printHtml += "<tr>";
|
||||
printHtml += "<th>药品名称</th>";
|
||||
printHtml += "<th>规格</th>";
|
||||
printHtml += "<th>单价</th>";
|
||||
printHtml += "<th>数量</th>";
|
||||
printHtml += "<th>金额</th>";
|
||||
printHtml += "<th>用法用量</th>";
|
||||
printHtml += "</tr>";
|
||||
printHtml += "</thead>";
|
||||
printHtml += "<tbody>";
|
||||
|
||||
prescriptionList.forEach((item) => {
|
||||
printHtml += "<tr>";
|
||||
printHtml += "<td>" + (item.medicineName || item.itemName || "N/A") + "</td>";
|
||||
printHtml += "<td>" + (item.totalVolume || item.spec || "") + "</td>";
|
||||
printHtml += "<td>" + (item.unitPrice || item.price || "0.00") + "</td>";
|
||||
printHtml +=
|
||||
"<td>" +
|
||||
(item.quantity || "N/A") +
|
||||
" " +
|
||||
(item.unitCode_dictText || item.unit || "") +
|
||||
"</td>";
|
||||
printHtml += "<td>" + (item.totalPrice || "0.00") + "</td>";
|
||||
|
||||
const usageInfo = [];
|
||||
if (item.dose && item.doseUnitCode_dictText) {
|
||||
usageInfo.push(item.dose + item.doseUnitCode_dictText);
|
||||
}
|
||||
if (item.methodCode_dictText || item.usage) {
|
||||
usageInfo.push(item.methodCode_dictText || item.usage);
|
||||
}
|
||||
if (item.frequency) {
|
||||
usageInfo.push(item.frequency);
|
||||
}
|
||||
printHtml += "<td>" + usageInfo.join("<br/>") + "</td>";
|
||||
printHtml += "</tr>";
|
||||
});
|
||||
|
||||
printHtml += "</tbody>";
|
||||
printHtml += "<tfoot>";
|
||||
printHtml += "<tr>";
|
||||
printHtml +=
|
||||
'<td colspan="4" style="text-align: right; font-weight: bold;">总计:</td>';
|
||||
printHtml +=
|
||||
'<td colspan="2" style="font-weight: bold;">' +
|
||||
(prescription.medTotalAmount || "0.00") +
|
||||
"</td>";
|
||||
printHtml += "</tr>";
|
||||
printHtml += "</tfoot>";
|
||||
printHtml += "</table>";
|
||||
} else {
|
||||
printHtml += "<p>暂无药品信息</p>";
|
||||
}
|
||||
|
||||
// 分页符(最后一个处方除外)
|
||||
if (index < result.length - 1) {
|
||||
printHtml += '<div class="page-break"></div>';
|
||||
}
|
||||
|
||||
printHtml += "</div>";
|
||||
});
|
||||
|
||||
printHtml += "</div>";
|
||||
printContainer.innerHTML = printHtml;
|
||||
|
||||
// 添加到文档
|
||||
document.body.appendChild(printContainer);
|
||||
|
||||
// 触发打印预览
|
||||
window.print();
|
||||
|
||||
// 打印完成后移除临时容器和样式
|
||||
const cleanup = () => {
|
||||
if (printContainer && document.body.contains(printContainer)) {
|
||||
document.body.removeChild(printContainer);
|
||||
}
|
||||
if (style && document.head.contains(style)) {
|
||||
document.head.removeChild(style);
|
||||
}
|
||||
window.removeEventListener("afterprint", cleanup);
|
||||
};
|
||||
|
||||
// 监听打印完成事件
|
||||
window.addEventListener("afterprint", cleanup);
|
||||
|
||||
// 添加超时清理
|
||||
setTimeout(() => {
|
||||
cleanup();
|
||||
}, 30000);
|
||||
|
||||
proxy.$modal.msgSuccess("打印预览已启动");
|
||||
|
||||
// 同时处理后台打印逻辑
|
||||
setTimeout(() => {
|
||||
handleBackgroundPrint(result);
|
||||
}, 500);
|
||||
} catch (error) {
|
||||
console.error("预览和打印过程出错:", error);
|
||||
proxy.$modal.msgError("操作失败: " + error.message);
|
||||
}
|
||||
}
|
||||
|
||||
// 后台打印逻辑,复用原有的打印功能
|
||||
function handleBackgroundPrint(result) {
|
||||
try {
|
||||
// 获取打印机列表
|
||||
const printers = getPrinterList();
|
||||
console.log("获取到的打印机列表:", printers);
|
||||
|
||||
if (printers.length === 0) {
|
||||
console.log("未检测到可用打印机,仅提供预览功能");
|
||||
return;
|
||||
}
|
||||
|
||||
// 设置打印机列表
|
||||
printerList.value = printers;
|
||||
|
||||
// 检查是否有缓存的打印机
|
||||
const cachedPrinter = getCachedPrinter();
|
||||
console.log("缓存的打印机:", cachedPrinter);
|
||||
|
||||
if (cachedPrinter && printers.some((printer) => printer.name === cachedPrinter)) {
|
||||
// 如果有缓存的打印机,直接使用
|
||||
selectedPrinter.value = cachedPrinter;
|
||||
confirmPrinter(result);
|
||||
} else {
|
||||
// 否则不自动显示打印机选择对话框,让用户在预览页面手动选择打印
|
||||
console.log("无缓存打印机,用户可在预览页面手动打印");
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("后台打印过程出错:", error);
|
||||
// 不显示错误提示,以免干扰用户在预览页面的操作
|
||||
}
|
||||
}
|
||||
|
||||
// 使用保存的打印数据执行打印
|
||||
function confirmPrinter(printData) {
|
||||
console.log("开始打印,传入数据:", printData);
|
||||
console.log("window临时数据:", window.currentPrintData);
|
||||
|
||||
// 如果没有传入数据,尝试从window临时变量获取
|
||||
let data = printData || window.currentPrintData;
|
||||
|
||||
if (!selectedPrinter.value) {
|
||||
proxy.$modal.msgWarning("请选择打印机");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!data || !Array.isArray(data) || data.length === 0) {
|
||||
proxy.$modal.msgError("没有找到有效的打印数据");
|
||||
showPrinterDialog.value = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!templateJson) {
|
||||
proxy.$modal.msgError("打印模板加载失败");
|
||||
showPrinterDialog.value = false;
|
||||
return;
|
||||
}
|
||||
|
||||
// 确保数据字段映射正确,特别是规格字段
|
||||
data = data.map((prescription) => {
|
||||
const mappedPrescription = { ...prescription };
|
||||
// 确保药品列表字段映射正确
|
||||
if (Array.isArray(prescription.prescriptionList)) {
|
||||
mappedPrescription.prescriptionList = prescription.prescriptionList.map((med) => ({
|
||||
...med,
|
||||
// 确保规格字段正确映射,优先使用totalVolume
|
||||
totalVolume: med.totalVolume || med.spec || "",
|
||||
// 确保其他关键字段存在
|
||||
medicineName: med.medicineName || med.itemName || "",
|
||||
unitPrice: med.unitPrice || med.price || 0,
|
||||
unitCode_dictText: med.unitCode_dictText || med.unit || "",
|
||||
methodCode_dictText: med.methodCode_dictText || med.usage || "",
|
||||
}));
|
||||
}
|
||||
return mappedPrescription;
|
||||
});
|
||||
console.log("处理后的打印数据:", data);
|
||||
|
||||
console.log("准备执行打印,打印机:", selectedPrinter.value);
|
||||
|
||||
// 使用his.js中的savePrinterToCache保存选择
|
||||
savePrinterToCache(selectedPrinter.value);
|
||||
|
||||
try {
|
||||
// 检查hiprint是否可用
|
||||
if (!window.hiprint) {
|
||||
throw new Error("打印插件未正确加载");
|
||||
}
|
||||
|
||||
// 直接使用hiprint执行打印,确保功能正常
|
||||
const hiprintTemplate = new window.hiprint.PrintTemplate({
|
||||
template: templateJson,
|
||||
});
|
||||
const printOptions = {
|
||||
title: "处方打印",
|
||||
height: 210,
|
||||
width: 148,
|
||||
printer: selectedPrinter.value,
|
||||
};
|
||||
|
||||
// 打印成功回调
|
||||
hiprintTemplate.on("printSuccess", function (e) {
|
||||
console.log("打印成功:", e);
|
||||
proxy.$modal.msgSuccess("打印成功");
|
||||
showPrinterDialog.value = false;
|
||||
// 清除临时数据
|
||||
window.currentPrintData = null;
|
||||
});
|
||||
|
||||
// 打印失败回调
|
||||
hiprintTemplate.on("printError", function (e) {
|
||||
console.error("打印失败:", e);
|
||||
proxy.$modal.msgError("打印失败,请检查打印机连接");
|
||||
showPrinterDialog.value = false;
|
||||
window.currentPrintData = null;
|
||||
});
|
||||
|
||||
// 执行打印
|
||||
console.log("调用hiprint.print2方法");
|
||||
hiprintTemplate.print2(data, printOptions);
|
||||
} catch (error) {
|
||||
console.error("打印执行出错:", error);
|
||||
proxy.$modal.msgError("打印执行失败: " + error.message);
|
||||
showPrinterDialog.value = false;
|
||||
window.currentPrintData = null;
|
||||
}
|
||||
=======
|
||||
// 获取所有唯一的doctorId
|
||||
const uniqueDoctorIds = [...new Set(selectedRows.map((row) => row.doctorId).filter((id) => id))];
|
||||
console.log('uniqueDoctorIds:', uniqueDoctorIds);
|
||||
@@ -1377,7 +728,6 @@ function confirmPrinter(printData) {
|
||||
});
|
||||
}
|
||||
});
|
||||
>>>>>>> v1.3
|
||||
}
|
||||
|
||||
// 取消打印机选择
|
||||
@@ -1403,8 +753,6 @@ function handleQuery() {
|
||||
}
|
||||
queryParams.value.pageNo = 1;
|
||||
getList();
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
}
|
||||
|
||||
function formatLotNumberLabel(row, item) {
|
||||
@@ -1432,7 +780,6 @@ function formatLotNumberLabel(row, item) {
|
||||
proxy.formatDateStr(item.expirationDate, 'YYYY-MM-DD')
|
||||
);
|
||||
}
|
||||
>>>>>>> v1.3
|
||||
}
|
||||
|
||||
function countGroupRows(data) {
|
||||
@@ -1448,20 +795,8 @@ function countGroupRows(data) {
|
||||
return groupCounts;
|
||||
}
|
||||
function getRowMarkers(groupCounts, data) {
|
||||
<<<<<<< HEAD
|
||||
const markers = new Array(data.length).fill("");
|
||||
|
||||
// ✅ 兼容 Map 和普通对象
|
||||
const entries =
|
||||
groupCounts instanceof Map
|
||||
? Array.from(groupCounts.entries())
|
||||
: Object.entries(groupCounts);
|
||||
|
||||
entries.forEach(([prescriptionNo, groupInfo]) => {
|
||||
=======
|
||||
const markers = new Array(data.length).fill('');
|
||||
groupCounts.forEach((groupInfo, prescriptionNo) => {
|
||||
>>>>>>> v1.3
|
||||
const { count, indices } = groupInfo;
|
||||
|
||||
if (count === 1) {
|
||||
@@ -1564,11 +899,7 @@ function formatPrice(row, column, cellValue) {
|
||||
|
||||
function tagType(statusEnum) {
|
||||
if (statusEnum == 2 || statusEnum == 2) {
|
||||
<<<<<<< HEAD
|
||||
return "default";
|
||||
=======
|
||||
return 'primary';
|
||||
>>>>>>> v1.3
|
||||
} else if (statusEnum == 4) {
|
||||
return "success";
|
||||
} else if (statusEnum == 5 || statusEnum == 6 || statusEnum == 7) {
|
||||
@@ -1581,10 +912,6 @@ function tagType(statusEnum) {
|
||||
function handleCurrentChange(row) {
|
||||
loading.value = true;
|
||||
currentRow.value = row; // 更新当前选中行的数据
|
||||
<<<<<<< HEAD
|
||||
console.log("当前选中行的数据:", currentRow.value);
|
||||
=======
|
||||
>>>>>>> v1.3
|
||||
currentRow.value.statusEnum = undefined;
|
||||
currentRow.value.dispenseStatus = queryParams.value.statusEnum;
|
||||
getAdjustPriceSwitchState().then((res) => {
|
||||
@@ -1643,12 +970,7 @@ function getMedicineList(encounterId) {
|
||||
loading.value = false;
|
||||
})
|
||||
.catch((error) => {
|
||||
<<<<<<< HEAD
|
||||
console.error("获取数据失败:", error);
|
||||
proxy.$modal.msgError("获取数据失败");
|
||||
=======
|
||||
proxy.$modal.msgError('获取数据失败');
|
||||
>>>>>>> v1.3
|
||||
});
|
||||
} else if (projectTypeCode.value == 2) {
|
||||
// 只调用listWesternmedicine接口
|
||||
@@ -1659,10 +981,6 @@ function getMedicineList(encounterId) {
|
||||
statusEnum: queryParams.value.statusEnum,
|
||||
tcmFlag: tcmFlag.value,
|
||||
}).then((response) => {
|
||||
<<<<<<< HEAD
|
||||
console.log("121212", response);
|
||||
=======
|
||||
>>>>>>> v1.3
|
||||
// personInfo.value = response.data.prescriptionPatientInfoDto;
|
||||
medicineInfoList.value = Array.isArray(response.data.records)
|
||||
? response.data.records
|
||||
@@ -1800,20 +1118,6 @@ function submitMedicine(saveList) {
|
||||
getMedicineList(currentRow.value.encounterId);
|
||||
})
|
||||
.catch((error) => {
|
||||
<<<<<<< HEAD
|
||||
console.error("发药失败:", error);
|
||||
proxy.$modal.msgError("发药失败: " + error.message);
|
||||
});
|
||||
} else if (projectTypeCode.value == 2) {
|
||||
prepareMedicion(saveList).then((res) => {
|
||||
if (res.code == 200) {
|
||||
updateMedicion(saveList).then((response) => {
|
||||
proxy.$modal.msgSuccess("发药成功");
|
||||
getMedicineList(currentRow.value.encounterId);
|
||||
});
|
||||
}
|
||||
});
|
||||
=======
|
||||
proxy.$modal.msgError('发药失败: ' + error.message);
|
||||
});
|
||||
} else if (projectTypeCode.value == 2) {
|
||||
@@ -1838,7 +1142,6 @@ function submitMedicine(saveList) {
|
||||
}
|
||||
});
|
||||
}
|
||||
>>>>>>> v1.3
|
||||
} else {
|
||||
deviceDispense(saveList).then((res) => {
|
||||
if (res.code == 200) {
|
||||
|
||||
Reference in New Issue
Block a user