feat(医生站): 添加处方单删除功能及相关UI

- 新增处方单删除按钮及交互逻辑
- 实现处方单删除前的条件检查(药品数量和收费状态)
- 添加删除按钮的样式和禁用状态
- 完善处方单药品数量和总价的计算方法
This commit is contained in:
py
2025-11-19 15:54:15 +08:00
parent 7ddf6211ee
commit f5db504363

View File

@@ -13,10 +13,19 @@
> >
<plus /> <plus />
</el-icon> </el-icon>
<el-icon
class="delete-icon"
title="删除处方单"
@click="handleDeletePrescriptionClick(index)"
:class="{ 'disabled-icon': isPrescriptionDeletable(index) !== true }"
style="font-size: 20px !important; margin-left: 10px; color: #f56c6c"
>
<minus />
</el-icon>
</div> </div>
<div class="summary"> <div class="summary">
<span class="summary-item">药品数: {{ '1' }}</span> <span class="summary-item">药品数: {{ getPrescriptionMedicineCount(index) }}</span>
<span class="summary-item">总价: ¥ {{ 100 }}</span> <span class="summary-item">总价: ¥ {{ getPrescriptionTotalPrice(index) }}</span>
</div> </div>
</div> </div>
<div> <div>
@@ -660,6 +669,51 @@ function addNewPrescription(){
tcmPrescriptionList.value.push({}) tcmPrescriptionList.value.push({})
} }
// 删除处方单
function handleDeletePrescriptionClick(prescriptionIndex) {
if (!isPrescriptionDeletable(prescriptionIndex)) {
const medicineCount = getPrescriptionMedicineCount(prescriptionIndex);
if (medicineCount > 0) {
proxy.$modal.msgWarning('该处方单还有药品,请先删除所有药品后再删除处方单');
return;
}
// 检查是否有已签发的药品
const hasChargedItems = prescriptionList.value.some(item => item.statusEnum === 2);
if (hasChargedItems) {
proxy.$modal.msgWarning('该处方单已收费,不能删除');
return;
}
}
// 确认删除
proxy.$modal.confirm('确定要删除这个处方单吗?').then(() => {
tcmPrescriptionList.value.splice(prescriptionIndex, 1);
proxy.$modal.msgSuccess('处方单删除成功');
}).catch(() => {
// 用户取消删除
});
}
// 检查处方是否可删除
function isPrescriptionDeletable(prescriptionIndex) {
const medicineCount = getPrescriptionMedicineCount(prescriptionIndex);
if (medicineCount > 0) {
return false;
}
// 检查是否有已签发的药品
const hasChargedItems = prescriptionList.value.some(item => item.statusEnum === 2);
return !hasChargedItems;
}
// 获取处方中的药品数量
function getPrescriptionMedicineCount(prescriptionIndex) {
// 这里需要根据实际的业务逻辑来计算
// 假设每个处方对应一组药品,这里简化处理
return prescriptionList.value.filter(item => item.statusEnum !== 2).length;
}
/** /**
* 选择药品回调 * 选择药品回调
*/ */
@@ -801,6 +855,37 @@ function handleDelete() {
groupMarkers.value = getGroupMarkers(prescriptionList.value); // 删除行会出现组号混乱的情况,所以这里重新更新标记 groupMarkers.value = getGroupMarkers(prescriptionList.value); // 删除行会出现组号混乱的情况,所以这里重新更新标记
} }
// 判断处方单是否可删除
function isPrescriptionDeletable(prescriptionIndex) {
// 条件1处方单没有药品
const medicineCount = getPrescriptionMedicineCount(prescriptionIndex);
if (medicineCount > 0) {
return false;
}
// 条件2处方单未收费已签发的处方不能删除
// 检查是否有已签发的药品statusEnum == 2 表示已签发)
const hasChargedItems = prescriptionList.value.some(item => item.statusEnum === 2);
if (hasChargedItems) {
return false;
}
return true;
}
// 删除处方单
function handleDeletePrescriptionClick(prescriptionIndex) {
if (!isPrescriptionDeletable(prescriptionIndex)) {
proxy.$modal.msgWarning('该处方单不可删除');
return;
}
proxy.$modal.confirm('确认删除该处方单吗?').then(() => {
tcmPrescriptionList.value.splice(prescriptionIndex, 1);
proxy.$modal.msgSuccess('删除成功');
}).catch(() => {});
}
function handleNumberClick(item, index) { function handleNumberClick(item, index) {
prescriptionList.value[index].unitPrice = item.price; prescriptionList.value[index].unitPrice = item.price;
// prescriptionList.value[index].lotNumber = item.lotNumber; // prescriptionList.value[index].lotNumber = item.lotNumber;
@@ -1599,6 +1684,90 @@ function validateGroups(saveList) {
} }
return true; return true;
} }
// 获取处方单药品数量
function getPrescriptionMedicineCount(prescriptionIndex) {
// 这里需要根据实际数据结构来判断暂时返回0
// TODO: 根据处方单索引获取对应的药品数量
return 0;
}
// 获取处方单总价
function getPrescriptionTotalPrice(prescriptionIndex) {
// 这里需要根据实际数据结构来判断暂时返回0
// TODO: 根据处方单索引获取对应的总价
return 0;
}
// 判断处方单是否可删除
function isPrescriptionDeletable(prescriptionIndex) {
// 条件1处方单没有药品
const medicineCount = getPrescriptionMedicineCount(prescriptionIndex);
if (medicineCount > 0) {
return false;
}
// 条件2处方单未收费这里需要根据实际收费状态字段判断
// TODO: 根据实际的收费状态字段来判断
// const isCharged = checkPrescriptionCharged(prescriptionIndex);
// if (isCharged) {
// return false;
// }
return true;
}
// 删除处方单
function handleDeletePrescriptionClick(prescriptionIndex) {
if (!isPrescriptionDeletable(prescriptionIndex)) {
const medicineCount = getPrescriptionMedicineCount(prescriptionIndex);
if (medicineCount > 0) {
proxy.$modal.msgWarning('该处方单还有药品,请先删除所有药品后再删除处方单');
} else {
proxy.$modal.msgWarning('该处方单已收费,不能删除');
}
return;
}
// 确认删除
proxy.$modal.confirm('确定要删除这个处方单吗?').then(() => {
tcmPrescriptionList.value.splice(prescriptionIndex, 1);
proxy.$modal.msgSuccess('处方单删除成功');
}).catch(() => {
// 用户取消删除
});
}
// 获取处方单药品数量
function getPrescriptionMedicineCount(prescriptionIndex) {
// 目前所有药品都在 prescriptionList 中,暂时返回总数量
// TODO: 将来需要按处方单分组药品
return prescriptionList.value.filter(item => item.statusEnum !== 2).length;
}
// 获取处方单总价
function getPrescriptionTotalPrice(prescriptionIndex) {
// 目前所有药品都在 prescriptionList 中,暂时返回总价
// TODO: 将来需要按处方单分组计算总价
return prescriptionList.value
.filter(item => item.statusEnum !== 2)
.reduce((total, item) => total + (Number(item.totalPrice) || 0), 0)
.toFixed(2);
}
// 判断处方单是否可删除
function isPrescriptionDeletable(prescriptionIndex) {
// 条件1处方单没有药品
const medicineCount = getPrescriptionMedicineCount(prescriptionIndex);
if (medicineCount > 0) {
return false;
}
// 条件2处方单未收费这里需要根据实际收费状态字段判断
// TODO: 根据实际的收费状态字段来判断
// 暂时返回true等有收费状态字段后再完善
return true;
}
defineExpose({ getListInfo, getDiagnosisInfo }); defineExpose({ getListInfo, getDiagnosisInfo });
</script> </script>
@@ -1711,4 +1880,25 @@ defineExpose({ getListInfo, getDiagnosisInfo });
.add-icon:hover { .add-icon:hover {
background-color: #ecf5ff; background-color: #ecf5ff;
} }
.delete-icon {
cursor: pointer;
border-radius: 50%;
padding: 4px;
transition: all 0.3s ease;
}
.delete-icon:hover {
background-color: #fef0f0;
}
.delete-icon.disabled-icon {
cursor: not-allowed;
color: #c0c4cc !important;
opacity: 0.6;
}
.delete-icon.disabled-icon:hover {
background-color: transparent;
}
</style> </style>