3 Commits

Author SHA1 Message Date
8810c678c9 Merge remote-tracking branch 'origin/develop' into develop 2026-03-03 14:17:40 +08:00
cd3155e63c feat(inventory): 扩展库存筛选功能支持多范围条件
- 将原有的库存是否为零筛选扩展为更灵活的库存范围筛选
- 新增多种库存数量筛选选项:无限制、等于0、大于0、小于等于20、小于等于50
- 使用switch语句重构筛选逻辑提高代码可读性
- 更新注释文档说明新的筛选参数含义
- 修改查询方法支持返回全部记录不分页的功能
2026-03-03 14:16:52 +08:00
45fdca65a7 fix(print): 修复处方打印功能并优化路由查询解析
- 使用全局用户存储替代代理访问医院名称
- 更改打印方法为浏览器打印预览方式,无需客户端连接
- 添加打印样式处理和回调函数
- 在主入口文件初始化hiprint并配置本地客户端连接
- 移除重复的路由查询解析逻辑,简化代码结构
2026-03-03 11:17:53 +08:00
4 changed files with 108 additions and 53 deletions

View File

@@ -86,7 +86,7 @@ public class ProductDetailAppServiceImpl extends ServiceImpl<InventoryItemMapper
List<String> medCategoryCodes = productDetailSearchParam.getMedCategoryCodes();
// 药品类型
List<String> devCategoryCodes = productDetailSearchParam.getDevCategoryCodes();
// 库存是否为零
// 库存范围
Integer zeroFlag = productDetailSearchParam.getZeroFlag();
// 过期天数
Integer remainingDays = productDetailSearchParam.getRemainingDays();
@@ -108,12 +108,29 @@ public class ProductDetailAppServiceImpl extends ServiceImpl<InventoryItemMapper
if (devCategoryCodes != null && !devCategoryCodes.isEmpty()) {
queryWrapper.in(CommonConstants.FieldName.DevCategoryCode, devCategoryCodes);
}
// 库存是否为零 (zeroFlag: 1=库存为零, 0=库存大于零)
// 库存范围筛选 (zeroFlag: 1=无限制, 2=数量等于0, 3=数量大于0, 4=数量<=20, 5=数量<=50)
if (zeroFlag != null) {
if (Integer.valueOf(1).equals(zeroFlag)) {
queryWrapper.eq(CommonConstants.FieldName.Quantity, BigDecimal.ZERO);
} else {
queryWrapper.gt(CommonConstants.FieldName.Quantity, BigDecimal.ZERO);
switch (zeroFlag) {
case 2:
// 数量等于0
queryWrapper.eq(CommonConstants.FieldName.Quantity, BigDecimal.ZERO);
break;
case 3:
// 数量大于0
queryWrapper.gt(CommonConstants.FieldName.Quantity, BigDecimal.ZERO);
break;
case 4:
// 数量小于等于20
queryWrapper.le(CommonConstants.FieldName.Quantity, new BigDecimal("20"));
break;
case 5:
// 数量小于等于50
queryWrapper.le(CommonConstants.FieldName.Quantity, new BigDecimal("50"));
break;
case 1:
default:
// 无限制,不添加筛选条件
break;
}
}
// 所在位置
@@ -132,7 +149,6 @@ public class ProductDetailAppServiceImpl extends ServiceImpl<InventoryItemMapper
Page<ProductDetailPageDto> productDetailsPage = productDetailsMapper.selectProductDetailsPage(
new Page<>(pageNo, pageSize), queryWrapper, CommonConstants.TableName.MED_MEDICATION_DEFINITION,
CommonConstants.TableName.ADM_DEVICE_DEFINITION, ConditionCode.LOT_NUMBER_COST.getCode());
// 库存明细
List<ProductDetailPageDto> productDetailList = productDetailsPage.getRecords();
if (productDetailList != null && !productDetailList.isEmpty()) {
// 医嘱定价来源
@@ -259,12 +275,29 @@ public class ProductDetailAppServiceImpl extends ServiceImpl<InventoryItemMapper
if (devCategoryCodes != null && !devCategoryCodes.isEmpty()) {
queryWrapper.in(CommonConstants.FieldName.DevCategoryCode, devCategoryCodes);
}
// 库存是否为零 (zeroFlag: 1=库存为零, 0=库存大于零)
// 库存范围筛选 (zeroFlag: 1=无限制, 2=数量等于0, 3=数量大于0, 4=数量<=20, 5=数量<=50)
if (zeroFlag != null) {
if (Integer.valueOf(1).equals(zeroFlag)) {
queryWrapper.eq(CommonConstants.FieldName.Quantity, BigDecimal.ZERO);
} else {
queryWrapper.gt(CommonConstants.FieldName.Quantity, BigDecimal.ZERO);
switch (zeroFlag) {
case 2:
// 数量等于0
queryWrapper.eq(CommonConstants.FieldName.Quantity, BigDecimal.ZERO);
break;
case 3:
// 数量大于0
queryWrapper.gt(CommonConstants.FieldName.Quantity, BigDecimal.ZERO);
break;
case 4:
// 数量小于等于20
queryWrapper.le(CommonConstants.FieldName.Quantity, new BigDecimal("20"));
break;
case 5:
// 数量小于等于50
queryWrapper.le(CommonConstants.FieldName.Quantity, new BigDecimal("50"));
break;
case 1:
default:
// 无限制,不添加筛选条件
break;
}
}
// 所在位置
@@ -507,12 +540,29 @@ public class ProductDetailAppServiceImpl extends ServiceImpl<InventoryItemMapper
if (devCategoryCodes != null && !devCategoryCodes.isEmpty()) {
queryWrapper.in(CommonConstants.FieldName.DevCategoryCode, devCategoryCodes);
}
// 库存是否为零 (zeroFlag: 1=库存为零, 0=库存大于零)
// 库存范围筛选 (zeroFlag: 1=无限制, 2=数量等于0, 3=数量大于0, 4=数量<=20, 5=数量<=50)
if (zeroFlag != null) {
if (Integer.valueOf(1).equals(zeroFlag)) {
queryWrapper.eq(CommonConstants.FieldName.Quantity, BigDecimal.ZERO);
} else {
queryWrapper.gt(CommonConstants.FieldName.Quantity, BigDecimal.ZERO);
switch (zeroFlag) {
case 2:
// 数量等于0
queryWrapper.eq(CommonConstants.FieldName.Quantity, BigDecimal.ZERO);
break;
case 3:
// 数量大于0
queryWrapper.gt(CommonConstants.FieldName.Quantity, BigDecimal.ZERO);
break;
case 4:
// 数量小于等于20
queryWrapper.le(CommonConstants.FieldName.Quantity, new BigDecimal("20"));
break;
case 5:
// 数量小于等于50
queryWrapper.le(CommonConstants.FieldName.Quantity, new BigDecimal("50"));
break;
case 1:
default:
// 无限制,不添加筛选条件
break;
}
}
// 所在位置
@@ -527,7 +577,7 @@ public class ProductDetailAppServiceImpl extends ServiceImpl<InventoryItemMapper
if (remainingDays != null) {
queryWrapper.le(CommonConstants.FieldName.RemainingDays, remainingDays);
}
// 查询库存商品明细分页列表
// 查询库存商品明细分页列表(不分页,查询全部)
List<ProductDetailPageDto> productDetailList = productDetailsMapper.getProductDetailPageAndTranslateField(
queryWrapper, CommonConstants.TableName.MED_MEDICATION_DEFINITION,
CommonConstants.TableName.ADM_DEVICE_DEFINITION, ConditionCode.LOT_NUMBER_COST.getCode());

View File

@@ -96,27 +96,6 @@ function resolvePath(routePath, routeQuery) {
return { path: getNormalPath(props.basePath + '/' + routePath), query: query }
} catch (e) {
// 如果解析失败,将其作为普通字符串处理
console.warn('Failed to parse routeQuery as JSON:', routeQuery, e);
return getNormalPath(props.basePath + '/' + routePath)
}
try {
let query = JSON.parse(routeQuery);
return { path: getNormalPath(props.basePath + '/' + routePath), query: query }
} catch (e) {
console.error('Failed to parse routeQuery:', routeQuery, e);
return getNormalPath(props.basePath + '/' + routePath)
}
try {
// 检查 routeQuery 是否已经是对象
if (typeof routeQuery === 'object') {
return { path: getNormalPath(props.basePath + '/' + routePath), query: routeQuery }
}
// 尝试解析 JSON 字符串
let query = JSON.parse(routeQuery);
return { path: getNormalPath(props.basePath + '/' + routePath), query: query }
} catch (e) {
// 如果解析失败,将其作为普通字符串处理
console.warn('Failed to parse routeQuery as JSON:', routeQuery, e);
return getNormalPath(props.basePath + '/' + routePath)
}
}

View File

@@ -3,7 +3,7 @@ import {createApp} from 'vue';
import Cookies from 'js-cookie';
// 导入 hiprint 并挂载到全局 window 对象
import {hiprint} from 'vue-plugin-hiprint';
import {hiprint, autoConnect, disAutoConnect} from 'vue-plugin-hiprint';
import ElementPlus, {ElDialog, ElMessage} from 'element-plus';
import zhCn from 'element-plus/es/locale/lang/zh-cn';
@@ -52,6 +52,32 @@ import {registerComponents} from './template';
window.hiprint = hiprint;
// 初始化 hiprint 并连接本地客户端
hiprint.init({
providers: []
});
// 延迟连接,确保 hiwebSocket 已初始化
setTimeout(() => {
if (hiprint.hiwebSocket) {
// 设置连接地址和 token
hiprint.hiwebSocket.setHost('http://localhost:17521', 'hiprint-test');
console.log('hiprint 连接地址:', hiprint.hiwebSocket.host);
// 等待连接建立
setTimeout(() => {
console.log('hiprint 连接状态:', hiprint.hiwebSocket.connected);
if (hiprint.hiwebSocket.connected) {
console.log('hiprint 客户端连接成功');
} else {
console.warn('hiprint 客户端未连接,请检查客户端是否运行');
}
}, 2000);
} else {
console.warn('hiprint.hiwebSocket 未初始化');
}
}, 500);
const app = createApp(App);
if (chrome.webview !== undefined) {

View File

@@ -465,6 +465,9 @@ import {hiprint} from 'vue-plugin-hiprint';
import templateJson from '@/components/Print/Pharmacy.json';
import chineseMedicineTemplateJson from '@/components/Print/ChineseMedicinePrescription.json';
import {formatInventory} from '../../../utils/his';
import useUserStore from '@/store/modules/user';
const userStore = useUserStore();
const {proxy} = getCurrentInstance();
const showSearch = ref(true);
@@ -718,21 +721,18 @@ async function printPrescription() {
// 根据药品分类选择对应的打印模板
const template = tcmFlag.value === '1' ? chineseMedicineTemplateJson : templateJson;
const printElements = JSON.parse(
JSON.stringify(template).replace(/{{HOSPITAL_NAME}}/g, proxy.$store.useUserStore().hospitalName)
JSON.stringify(template).replace(/{{HOSPITAL_NAME}}/g, userStore.hospitalName)
);
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('打印失败');
proxy.$modal.msgError('打印失败,请检查打印机连接');
// 使用浏览器打印预览方式(不需要客户端连接)
hiprintTemplate.print(result, {}, {
styleHandler: () => {
return '<style>@media print { @page { margin: 0; } }</style>';
},
callback: () => {
console.log('打印窗口已打开');
}
});
} catch (error) {
console.error('处方打印失败:', error);