From a1be7fdbfd1da6555209b7baab933fdd6a1c6d32 Mon Sep 17 00:00:00 2001 From: Auora <14587305+auoraasd@user.noreply.gitee.com> Date: Fri, 31 Oct 2025 09:01:35 +0800 Subject: [PATCH] =?UTF-8?q?[bug]=E4=BF=AE=E6=94=B9=E4=BB=93=E5=BA=93?= =?UTF-8?q?=E5=AD=97=E6=AE=B5=E4=B8=8B=E6=8B=89=E5=88=AB=E8=A1=A8=E6=97=A0?= =?UTF-8?q?=E5=86=85=E5=AE=B9bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../purchaseDocument/components/api.js | 23 +++++-- .../purchaseDocument/index.vue | 63 ++++++++++++++++--- 2 files changed, 75 insertions(+), 11 deletions(-) diff --git a/openhis-ui-vue3/src/views/medicationmanagement/purchaseDocument/components/api.js b/openhis-ui-vue3/src/views/medicationmanagement/purchaseDocument/components/api.js index 74be2dd4..75689307 100644 --- a/openhis-ui-vue3/src/views/medicationmanagement/purchaseDocument/components/api.js +++ b/openhis-ui-vue3/src/views/medicationmanagement/purchaseDocument/components/api.js @@ -87,23 +87,38 @@ export function getCount(queryParams) { }) } -// 获取药房列表 +// 获取药房列表(权限过滤) export function getPharmacyList() { return request({ url: '/app-common/inventory-pharmacy-list', - // '/app-common/pharmacy-list', method: 'get', }) } -// 获取药库列表 +// 获取药库列表(权限过滤) export function getDispensaryList() { return request({ url: '/app-common/inventory-cabinet-list', - // '/app-common/cabinet-list', method: 'get', }) } + +// 获取药房列表(不受权限过滤,作为回退) +export function getPharmacyListAll() { + return request({ + url: '/app-common/pharmacy-list', + method: 'get', + }) +} + +// 获取药库列表(不受权限过滤,作为回退) +export function getDispensaryListAll() { + return request({ + url: '/app-common/cabinet-list', + method: 'get', + }) +} + /** * 审批驳回 */ diff --git a/openhis-ui-vue3/src/views/medicationmanagement/purchaseDocument/index.vue b/openhis-ui-vue3/src/views/medicationmanagement/purchaseDocument/index.vue index 50981c80..dccb678d 100644 --- a/openhis-ui-vue3/src/views/medicationmanagement/purchaseDocument/index.vue +++ b/openhis-ui-vue3/src/views/medicationmanagement/purchaseDocument/index.vue @@ -130,8 +130,8 @@ - - + + 添加行 @@ -635,6 +635,8 @@ import { getInitBusNo, purchaseInventoryApproved, reject, + getPharmacyListAll, + getDispensaryListAll, } from './components/api'; const route = useRoute(); import PopoverList from '@/components/OpenHis/popoverList/index.vue'; @@ -821,7 +823,8 @@ function addNewRow() { remake: '', supplierId: '', purposeTypeEnum: '', - purposeLocationId: null, + // 使用表头的仓库作为新增行默认值,减少重复选择 + purposeLocationId: receiptHeaderForm.purposeLocationId || null, purposeLocationStoreId: null, practitionerId: '', traceNo: '', @@ -1124,11 +1127,25 @@ function changeValEnd(val, index) { function handleChangeLocationType(value) { if (value == 16) { getPharmacyList().then((res) => { - locationList.value = res.data; + const list = res?.data || []; + if (!list.length) { + getPharmacyListAll().then((res2) => { + locationList.value = res2?.data || []; + }); + } else { + locationList.value = list; + } }); } else if (value == 11) { getDispensaryList().then((res) => { - locationList.value = res.data; + const list = res?.data || []; + if (!list.length) { + getDispensaryListAll().then((res2) => { + locationList.value = res2?.data || []; + }); + } else { + locationList.value = list; + } }); } } @@ -1406,7 +1423,9 @@ function show() { visible.value = true; getPurchaseinventoryTypeList(); getInitBusNo().then((res) => { - receiptHeaderForm.busNo = res.data.busNo; + if (res.data && res.data.busNo) { + receiptHeaderForm.busNo = res.data.busNo; + } }); // supplierListOptions.value = props.supplierListOptions; // itemTypeOptions.value = props.itemTypeOptions; @@ -1428,6 +1447,11 @@ function edit() { // itemTypeOptions.value = props.itemTypeOptions; // practitionerListOptions.value = props.practitionerListOptions; // receiptHeaderForm.busNo = props.busNoAdd; + // 确保数据存在 + if (!editData.value.item || editData.value.item.length === 0) { + proxy.$message.warning('没有可编辑的数据'); + return; + } receiptHeaderForm.value = editData.value.item.length > 0 ? editData.value.item[0] : {}; receiptHeaderForm.busNo = editData.value.editRow.supplyBusNo; receiptHeaderForm.supplierId = editData.value.editRow.supplierId; @@ -1463,6 +1487,10 @@ function edit() { volume: item.totalVolume, manufacturer: item.supplierName, quantity: item.totalQuantity, + // 确保仓库字段回显 + purposeLocationId: item.purposeLocationId || editData.value.editRow?.purposeLocationId || null, + locationStoreName: item.locationStoreName || '', + purposeLocationStoreId: item.purposeLocationStoreId || null, // locationInventoryList: locationList.value, startTime: formatDateymd(item.startTime), endTime: formatDateymd(item.endTime), @@ -1475,6 +1503,27 @@ function edit() { console.log(form.purchaseinventoryList, 'purchaseinventoryList.value'); console.log(receiptHeaderForm, 'receiptHeaderForm'); loading.value = false; + // 使用 Promise 确保数据加载完成 + Promise.resolve().then(() => { + form.purchaseinventoryList = editData.value.item.map((item) => { + return { + ...item, + name: item.itemName, + volume: item.totalVolume, + manufacturer: item.supplierName, + quantity: item.totalQuantity, + // 仓库字段回显(Promise 阶段再保障一次) + purposeLocationId: item.purposeLocationId || editData.value.editRow?.purposeLocationId || null, + locationStoreName: item.locationStoreName || '', + purposeLocationStoreId: item.purposeLocationStoreId || null, + startTime: formatDateymd(item.startTime), + endTime: formatDateymd(item.endTime), + applyTime: formatDate(item.applyTime), + isSave: true, + }; + }); + }); + } function getPurchaseinventoryTypeList() { @@ -1485,7 +1534,7 @@ function getPurchaseinventoryTypeList() { }); } -// 驳回 +// reject function handleReject() { reject(route.query.supplyBusNo).then((res) => { if (res.code == 200) {