修复了打印单据没有响应的错误,修复了新增加诊断诊断类别自动获取11的错误
This commit is contained in:
@@ -439,7 +439,7 @@ function handleAddDiagnosis() {
|
|||||||
showPopover: false,
|
showPopover: false,
|
||||||
name: undefined,
|
name: undefined,
|
||||||
verificationStatusEnum: 4,
|
verificationStatusEnum: 4,
|
||||||
medTypeCode: '11',
|
medTypeCode: '初诊诊断',
|
||||||
diagSrtNo: maxSortNo + 1,
|
diagSrtNo: maxSortNo + 1,
|
||||||
iptDiseTypeCode: 2,
|
iptDiseTypeCode: 2,
|
||||||
diagnosisDesc: '',
|
diagnosisDesc: '',
|
||||||
|
|||||||
@@ -30,7 +30,8 @@
|
|||||||
<el-button type="primary" plain icon="Plus" @click="handleSave">批量保存</el-button>
|
<el-button type="primary" plain icon="Plus" @click="handleSave">批量保存</el-button>
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
<el-button type="primary" plain icon="Printer" @click="handlePrint"> 打印单据 </el-button>
|
<el-button type="primary" icon="View" @click="handlePrintPreview"> 预览单据 </el-button>
|
||||||
|
<el-button type="success" plain icon="Printer" @click="handlePrint"> 打印单据 </el-button>
|
||||||
<el-form
|
<el-form
|
||||||
:model="receiptHeaderForm"
|
:model="receiptHeaderForm"
|
||||||
ref="receiptHeaderRef"
|
ref="receiptHeaderRef"
|
||||||
@@ -645,6 +646,7 @@ import TraceNoDialog from '@/components/OpenHis/TraceNoDialog/index.vue';
|
|||||||
import { formatDate, formatDateymd } from '@/utils/index';
|
import { formatDate, formatDateymd } from '@/utils/index';
|
||||||
import { useStore } from '@/store/store';
|
import { useStore } from '@/store/store';
|
||||||
import useUserStore from '@/store/modules/user';
|
import useUserStore from '@/store/modules/user';
|
||||||
|
import { ElMessage } from 'element-plus';
|
||||||
import { nextTick, ref, watch } from 'vue';
|
import { nextTick, ref, watch } from 'vue';
|
||||||
import useTagsViewStore from '@/store/modules/tagsView';
|
import useTagsViewStore from '@/store/modules/tagsView';
|
||||||
import _, { isEqual } from 'lodash';
|
import _, { isEqual } from 'lodash';
|
||||||
@@ -1320,27 +1322,193 @@ function handleSelectionChange(selection) {
|
|||||||
multiple.value = !selection.length;
|
multiple.value = !selection.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
function handlePrint() {
|
// 预览单据函数 - 简化实现,避免复杂嵌套数据结构
|
||||||
const result = [];
|
function handlePrintPreview() {
|
||||||
let supplierName = supplierListOptions.value.filter((item) => {
|
console.log('开始执行预览功能');
|
||||||
|
|
||||||
|
// 检查是否存在数据
|
||||||
|
if (!form.purchaseinventoryList || form.purchaseinventoryList.length === 0) {
|
||||||
|
ElMessage.warning('没有数据可预览');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检查是否所有必填字段都已填写
|
||||||
|
const hasEmptyFields = form.purchaseinventoryList.some(row => {
|
||||||
|
return !row.name || !row.itemQuantity || !row.price || !row.totalPrice;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (hasEmptyFields) {
|
||||||
|
ElMessage.warning('请确保所有药品信息完整后再预览');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检查templateJson是否已正确导入
|
||||||
|
if (!templateJson) {
|
||||||
|
console.error('错误:templateJson未定义,请检查导入');
|
||||||
|
ElMessage.error('打印模板未加载,请刷新页面重试');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 安全获取供应商名称
|
||||||
|
let supplierName = '';
|
||||||
|
if (supplierListOptions.value && receiptHeaderForm.supplierId) {
|
||||||
|
const filteredSuppliers = supplierListOptions.value.filter((item) => {
|
||||||
return item.value == receiptHeaderForm.supplierId;
|
return item.value == receiptHeaderForm.supplierId;
|
||||||
})[0].label;
|
});
|
||||||
|
supplierName = filteredSuppliers.length > 0 ? filteredSuppliers[0].label : '';
|
||||||
|
}
|
||||||
|
|
||||||
|
// 计算总金额
|
||||||
const totalAmount = form.purchaseinventoryList.reduce((accumulator, currentRow) => {
|
const totalAmount = form.purchaseinventoryList.reduce((accumulator, currentRow) => {
|
||||||
return accumulator + (Number(currentRow.totalPrice) || 0);
|
return accumulator + (Number(currentRow.totalPrice) || 0);
|
||||||
}, 0);
|
}, 0);
|
||||||
result.push({
|
|
||||||
supplierName: supplierName,
|
// 重新构建包含药品清单的数据结构
|
||||||
|
const simpleData = {
|
||||||
|
supplierName: supplierName || '',
|
||||||
totalAmount: totalAmount.toFixed(2),
|
totalAmount: totalAmount.toFixed(2),
|
||||||
...receiptHeaderForm,
|
receiptNumber: receiptHeaderForm.receiptNumber || '',
|
||||||
purchaseinventoryList: form.purchaseinventoryList,
|
receiptDate: receiptHeaderForm.receiptDate || '',
|
||||||
|
organizationName: receiptHeaderForm.organizationName || '',
|
||||||
|
// 重新添加药品清单数组,但确保格式安全
|
||||||
|
purchaseinventoryList: Array.isArray(form.purchaseinventoryList) ? form.purchaseinventoryList.map(item => ({
|
||||||
|
id: item.id || '',
|
||||||
|
name: item.name || '',
|
||||||
|
itemQuantity: item.itemQuantity || 0,
|
||||||
|
price: item.price || 0,
|
||||||
|
totalPrice: item.totalPrice || 0,
|
||||||
|
// 保留其他可能需要的字段
|
||||||
|
...item
|
||||||
|
})) : []
|
||||||
|
};
|
||||||
|
|
||||||
|
console.log('简化后的预览数据:', simpleData);
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 直接使用templateJson创建打印
|
||||||
|
// 避免复杂的模板创建和数据处理逻辑
|
||||||
|
setTimeout(() => {
|
||||||
|
try {
|
||||||
|
// 最简单的方式使用hiprint - 直接调用print2方法
|
||||||
|
// 只传递必要的数据,不传递复杂嵌套的数组
|
||||||
|
const printOptions = {
|
||||||
|
preview: true,
|
||||||
|
title: '药品采购入库清单',
|
||||||
|
printer: ''
|
||||||
|
};
|
||||||
|
|
||||||
|
// 方法1: 尝试直接使用templateJson
|
||||||
|
console.log('尝试直接使用templateJson');
|
||||||
|
if (typeof hiprint.template !== 'undefined' && typeof hiprint.template.print === 'function') {
|
||||||
|
hiprint.template.print(templateJson, simpleData, printOptions);
|
||||||
|
}
|
||||||
|
// 方法2: 尝试创建简单模板
|
||||||
|
else if (typeof hiprint.PrintTemplate === 'function') {
|
||||||
|
console.log('尝试使用PrintTemplate');
|
||||||
|
const template = new hiprint.PrintTemplate({template: templateJson});
|
||||||
|
template.print(simpleData, printOptions);
|
||||||
|
}
|
||||||
|
// 方法3: 最直接的方式
|
||||||
|
else {
|
||||||
|
console.log('尝试最直接的打印方式');
|
||||||
|
hiprint.print(templateJson, simpleData, printOptions);
|
||||||
|
}
|
||||||
|
|
||||||
|
ElMessage.success('正在生成单据预览,请等待...');
|
||||||
|
} catch (e) {
|
||||||
|
console.error('预览执行失败:', e);
|
||||||
|
ElMessage.error('预览功能执行失败,请稍后重试');
|
||||||
|
}
|
||||||
|
}, 50);
|
||||||
|
} catch (error) {
|
||||||
|
console.error('预览准备失败:', error);
|
||||||
|
ElMessage.error('预览失败,请检查配置');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 打印单据函数 - 简化实现,与预览函数保持一致
|
||||||
|
function handlePrint() {
|
||||||
|
// 检查是否存在数据
|
||||||
|
if (!form.purchaseinventoryList || form.purchaseinventoryList.length === 0) {
|
||||||
|
ElMessage.warning('没有数据可打印');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检查是否所有必填字段都已填写
|
||||||
|
const hasEmptyFields = form.purchaseinventoryList.some(row => {
|
||||||
|
return !row.name || !row.itemQuantity || !row.price || !row.totalPrice;
|
||||||
});
|
});
|
||||||
console.log(result, '345678987654');
|
|
||||||
const printElements = templateJson;
|
if (hasEmptyFields) {
|
||||||
var hiprintTemplate = new hiprint.PrintTemplate({ template: printElements }); // 定义模板
|
ElMessage.warning('请确保所有药品信息完整后再打印');
|
||||||
hiprintTemplate.print2(result, {
|
return;
|
||||||
printer: 'EPSON LQ-80KFII',
|
}
|
||||||
title: '打印标题',
|
|
||||||
}); //开始打印
|
// 安全获取供应商名称
|
||||||
|
let supplierName = '';
|
||||||
|
if (supplierListOptions.value && receiptHeaderForm.supplierId) {
|
||||||
|
const filteredSuppliers = supplierListOptions.value.filter((item) => {
|
||||||
|
return item.value == receiptHeaderForm.supplierId;
|
||||||
|
});
|
||||||
|
supplierName = filteredSuppliers.length > 0 ? filteredSuppliers[0].label : '';
|
||||||
|
}
|
||||||
|
|
||||||
|
// 计算总金额
|
||||||
|
const totalAmount = form.purchaseinventoryList.reduce((accumulator, currentRow) => {
|
||||||
|
return accumulator + (Number(currentRow.totalPrice) || 0);
|
||||||
|
}, 0);
|
||||||
|
|
||||||
|
// 重新构建包含药品清单的数据结构
|
||||||
|
const simpleData = {
|
||||||
|
supplierName: supplierName || '',
|
||||||
|
totalAmount: totalAmount.toFixed(2),
|
||||||
|
receiptNumber: receiptHeaderForm.receiptNumber || '',
|
||||||
|
receiptDate: receiptHeaderForm.receiptDate || '',
|
||||||
|
organizationName: receiptHeaderForm.organizationName || '',
|
||||||
|
// 重新添加药品清单数组,但确保格式安全
|
||||||
|
purchaseinventoryList: Array.isArray(form.purchaseinventoryList) ? form.purchaseinventoryList.map(item => ({
|
||||||
|
id: item.id || '',
|
||||||
|
name: item.name || '',
|
||||||
|
itemQuantity: item.itemQuantity || 0,
|
||||||
|
price: item.price || 0,
|
||||||
|
totalPrice: item.totalPrice || 0,
|
||||||
|
// 保留其他可能需要的字段
|
||||||
|
...item
|
||||||
|
})) : []
|
||||||
|
};
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 使用与预览函数相同的简化打印逻辑
|
||||||
|
setTimeout(() => {
|
||||||
|
try {
|
||||||
|
const printOptions = {
|
||||||
|
preview: false, // 直接打印模式
|
||||||
|
title: '药品采购入库清单',
|
||||||
|
printer: ''
|
||||||
|
};
|
||||||
|
|
||||||
|
// 尝试多种可能的API调用方式
|
||||||
|
if (typeof hiprint.template !== 'undefined' && typeof hiprint.template.print === 'function') {
|
||||||
|
hiprint.template.print(templateJson, simpleData, printOptions);
|
||||||
|
}
|
||||||
|
else if (typeof hiprint.PrintTemplate === 'function') {
|
||||||
|
const template = new hiprint.PrintTemplate({template: templateJson});
|
||||||
|
template.print(simpleData, printOptions);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
hiprint.print(templateJson, simpleData, printOptions);
|
||||||
|
}
|
||||||
|
|
||||||
|
ElMessage.success('打印请求已发送');
|
||||||
|
} catch (e) {
|
||||||
|
console.error('打印执行失败:', e);
|
||||||
|
ElMessage.error('打印执行失败,请稍后重试');
|
||||||
|
}
|
||||||
|
}, 50);
|
||||||
|
} catch (error) {
|
||||||
|
console.error('打印失败:', error);
|
||||||
|
ElMessage.error('打印失败,请检查配置');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function deleteSelectedRows() {
|
function deleteSelectedRows() {
|
||||||
|
|||||||
Reference in New Issue
Block a user