diff --git a/openhis-ui-vue3/src/views/medicationmanagement/purchaseDocument/index.vue b/openhis-ui-vue3/src/views/medicationmanagement/purchaseDocument/index.vue index 4100d66f..4fb6690d 100644 --- a/openhis-ui-vue3/src/views/medicationmanagement/purchaseDocument/index.vue +++ b/openhis-ui-vue3/src/views/medicationmanagement/purchaseDocument/index.vue @@ -94,6 +94,7 @@ style="width: 150px" :disabled="viewStatus == 'view' || viewStatus == 'apply'" v-if="viewStatus != 'apply' && viewStatus != 'view'" + @change="handleSupplierChange" > + + + + + - - - 添加行 + + + 添加行 + + + 删除行 + + +
+ - - - 删除行 - - + + +
+ - - - - - - { return form.purchaseinventoryList.length > 0; }); + +const filteredPurchaseinventoryList = computed(() => { + if (!detailSearchKey.value) { + return form.purchaseinventoryList; + } + const searchKey = detailSearchKey.value.toLowerCase(); + return form.purchaseinventoryList.filter(item => { + const nameMatch = item.name && item.name.toLowerCase().includes(searchKey); + const manufacturerMatch = item.manufacturerText && item.manufacturerText.toLowerCase().includes(searchKey); + const lotNumberMatch = item.lotNumber && item.lotNumber.toLowerCase().includes(searchKey); + return nameMatch || manufacturerMatch || lotNumberMatch; + }); +}); const rowList = ref([]); const saveRowObject = ref({}); @@ -937,7 +911,8 @@ function addNewRow() { if (!row.unitCode) { errors.push('计量单位'); } - if (!row.purposeLocationId) { + // 仓库校验改为检查表头 + if (!receiptHeaderForm.headerLocationId) { errors.push('仓库'); } if (!row.itemQuantity || row.itemQuantity === '' || row.itemQuantity === 0) { @@ -1057,6 +1032,7 @@ function handleBlur(row, index) { row.occurrenceTime = receiptHeaderForm.occurrenceTime; row.supplierId = receiptHeaderForm.supplierId; row.purposeTypeEnum = receiptHeaderForm.purposeTypeEnum; + row.purposeLocationId = receiptHeaderForm.headerLocationId; } const handleMouseEnter = (row, column, cell, event) => {}; @@ -1231,8 +1207,109 @@ function changeValEnd(val, index) { } } } + +// 切换供应商前检查 +function handleSupplierChange(value) { + if (form.purchaseinventoryList.length > 0 && value !== receiptHeaderForm.supplierId) { + ElMessageBox.confirm( + '切换供应商将清空当前表格数据,是否继续?', + '系统提示', + { + confirmButtonText: '确定', + cancelButtonText: '取消', + confirmButtonClass: 'el-button--primary', + cancelButtonClass: 'el-button', + type: 'warning', + } + ).then(() => { + receiptHeaderForm.supplierId = value; + form.purchaseinventoryList = []; + }).catch(() => { + // 取消操作,什么都不做 + }); + } else { + receiptHeaderForm.supplierId = value; + } +} + +// 切换药品类型前检查 +function handleMedicationTypeChange(value) { + if (form.purchaseinventoryList.length > 0 && value !== receiptHeaderForm.medicationType) { + ElMessageBox.confirm( + '切换药品类型将清空当前表格数据,是否继续?', + '系统提示', + { + confirmButtonText: '确定', + cancelButtonText: '取消', + confirmButtonClass: 'el-button--primary', + cancelButtonClass: 'el-button', + type: 'warning', + } + ).then(() => { + receiptHeaderForm.medicationType = value; + itemType.value = value; + form.purchaseinventoryList = []; + }).catch(() => { + // 取消操作,什么都不做 + }); + } else { + receiptHeaderForm.medicationType = value; + itemType.value = value; + } +} + +// 点击仓库类型下拉框展开时检查 +function handlePurposeTypeEnumVisibleChange(visible) { + if (visible && form.purchaseinventoryList.length > 0) { + ElMessageBox.confirm( + '切换仓库类型将清空当前表格数据,是否继续?', + '系统提示', + { + confirmButtonText: '确定', + cancelButtonText: '取消', + confirmButtonClass: 'el-button--primary', + cancelButtonClass: 'el-button', + type: 'warning', + closeOnClickModal: false, + } + ).then(() => { + receiptHeaderForm.purposeTypeEnum = null; + receiptHeaderForm.headerLocationId = null; + form.purchaseinventoryList = []; + }).catch(() => { + receiptHeaderForm.purposeTypeEnum = receiptHeaderForm.purposeTypeEnum; + }); + } +} + +// 点击仓库下拉框展开时检查 +function handleHeaderLocationVisibleChange(visible) { + if (visible && form.purchaseinventoryList.length > 0) { + ElMessageBox.confirm( + '切换仓库将清空当前表格数据,是否继续?', + '系统提示', + { + confirmButtonText: '确定', + cancelButtonText: '取消', + confirmButtonClass: 'el-button--primary', + cancelButtonClass: 'el-button', + type: 'warning', + closeOnClickModal: false, + } + ).then(() => { + receiptHeaderForm.headerLocationId = null; + form.purchaseinventoryList = []; + }).catch(() => { + receiptHeaderForm.headerLocationId = receiptHeaderForm.headerLocationId; + }); + } +} + // 切换仓库类型获取药房/药库/耗材库列表 function handleChangeLocationType(value) { + // 切换仓库类型时清空已选仓库 + receiptHeaderForm.headerLocationId = null; + // 确保locationList变量已初始化 if (!locationList) { console.warn("locationList未初始化"); @@ -1373,7 +1450,7 @@ function handleSave(row, index) { rowList.value.push(JSON.parse(JSON.stringify(row))); if ( rowList._rawValue && - rowList._rawValue.length == form.purchaseinventoryList.length + rowList._rawValue.length === form.purchaseinventoryList.length ) { addPurchaseinventorys(rowList._rawValue); } @@ -1739,7 +1816,10 @@ function reset() { supplierId: undefined, medicationType: "1", purposeTypeEnum: undefined, + headerLocationId: null, }); + // 重置搜索关键字 + detailSearchKey.value = ''; // 重置编辑数据 editData.value = {}; } @@ -1775,6 +1855,7 @@ function edit() { : editData.value.item[0].purposeTypeEnum.toString(); receiptHeaderForm.medicationType = editData.value.item[0].itemTable == "med_medication_definition" ? "1" : "2"; + receiptHeaderForm.headerLocationId = editData.value.editRow?.purposeLocationId || null; total.value = form.purchaseinventoryList.length; handleChangeLocationType( editData.value.editRow.purposeTypeEnum