修复采购入库时选择不同仓库新增药品时仓库的错误
This commit is contained in:
@@ -769,7 +769,7 @@ watch(
|
||||
} else {
|
||||
editData.value = {};
|
||||
show();
|
||||
}
|
||||
}
|
||||
},
|
||||
{ immediate: true }
|
||||
);
|
||||
@@ -1154,9 +1154,10 @@ function changeValEnd(val, index) {
|
||||
}
|
||||
}
|
||||
}
|
||||
// 切换仓库类型获取药房/药库列表
|
||||
// 切换仓库类型获取药房/药库/耗材库列表
|
||||
function handleChangeLocationType(value) {
|
||||
if (value == 16) {
|
||||
// 药房类型
|
||||
getPharmacyList().then((res) => {
|
||||
const list = res?.data || [];
|
||||
if (!list.length) {
|
||||
@@ -1167,16 +1168,49 @@ function handleChangeLocationType(value) {
|
||||
locationList.value = list;
|
||||
}
|
||||
});
|
||||
} else if (value == 17) {
|
||||
getDispensaryList().then((res) => {
|
||||
const list = res?.data || [];
|
||||
if (!list.length) {
|
||||
getDispensaryListAll().then((res2) => {
|
||||
locationList.value = res2?.data || [];
|
||||
});
|
||||
} else {
|
||||
locationList.value = list;
|
||||
} else if (value == 11) {
|
||||
// 根据用户说明,标识为11的是药库
|
||||
// 直接使用getDispensaryListAll获取药库数据,而不是从药房数据中过滤
|
||||
getDispensaryListAll().then((res) => {
|
||||
const pharmacies = res?.data || [];
|
||||
console.log('===== 药库数据获取结果 =====');
|
||||
console.log('获取到的药库数量:', pharmacies.length);
|
||||
console.log('药库列表:', pharmacies);
|
||||
|
||||
// 直接使用获取到的药库数据
|
||||
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);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user