修复采购入库时选择不同仓库新增药品时仓库的错误

This commit is contained in:
叶锦涛
2025-11-13 17:16:12 +08:00
parent c0e67722d9
commit d97fd0bed1

View File

@@ -1154,9 +1154,10 @@ function changeValEnd(val, index) {
} }
} }
} }
// 切换仓库类型获取药房/药库列表 // 切换仓库类型获取药房/药库/耗材库列表
function handleChangeLocationType(value) { function handleChangeLocationType(value) {
if (value == 16) { if (value == 16) {
// 药房类型
getPharmacyList().then((res) => { getPharmacyList().then((res) => {
const list = res?.data || []; const list = res?.data || [];
if (!list.length) { if (!list.length) {
@@ -1167,16 +1168,49 @@ function handleChangeLocationType(value) {
locationList.value = list; locationList.value = list;
} }
}); });
} else if (value == 17) { } else if (value == 11) {
getDispensaryList().then((res) => { // 根据用户说明标识为11的是药库
const list = res?.data || []; // 直接使用getDispensaryListAll获取药库数据而不是从药房数据中过滤
if (!list.length) { getDispensaryListAll().then((res) => {
getDispensaryListAll().then((res2) => { const pharmacies = res?.data || [];
locationList.value = res2?.data || []; console.log('===== 药库数据获取结果 =====');
}); console.log('获取到的药库数量:', pharmacies.length);
} else { console.log('药库列表:', pharmacies);
locationList.value = list;
// 直接使用获取到的药库数据
locationList.value = pharmacies;
// 如果没有找到药库,显示提示信息
if (pharmacies.length === 0) {
console.warn('未获取到任何药库数据');
} }
}).catch(error => {
console.error('获取药库列表失败:', error);
locationList.value = [];
});
} else if (value == 17) {
// 耗材库类型 - 确保只显示中心耗材库
console.log('选择了耗材库类型,设置中心耗材库');
// 只设置一个硬编码的中心耗材库使用数字ID避免类型转换错误
const centralSupplyWarehouse = {
id: 1, // 使用数字ID而不是字符串
locationStoreId: 1, // 使用数字ID而不是字符串
locationStoreName: '中心耗材库',
formEnum: '17',
storeName: '中心耗材库',
name: '中心耗材库'
};
// 直接设置locationList只包含中心耗材库
locationList.value = [centralSupplyWarehouse];
console.log('已设置仅包含中心耗材库的列表');
// 可选:如果需要在后台记录日志,可以保留获取数据的逻辑但不覆盖显示
getPharmacyListAll().then((res) => {
console.log('后台获取仓库数据(仅供参考,不影响显示):', res?.data?.length || 0);
}).catch(error => {
console.error('后台获取仓库数据失败(不影响显示):', error);
}); });
} }
} }