From f5db50436360496aaf688c1ead00a9e365c3a601 Mon Sep 17 00:00:00 2001
From: py <2901848092@qq.com>
Date: Wed, 19 Nov 2025 15:54:15 +0800
Subject: [PATCH] =?UTF-8?q?feat(=E5=8C=BB=E7=94=9F=E7=AB=99):=20=E6=B7=BB?=
=?UTF-8?q?=E5=8A=A0=E5=A4=84=E6=96=B9=E5=8D=95=E5=88=A0=E9=99=A4=E5=8A=9F?=
=?UTF-8?q?=E8=83=BD=E5=8F=8A=E7=9B=B8=E5=85=B3UI?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- 新增处方单删除按钮及交互逻辑
- 实现处方单删除前的条件检查(药品数量和收费状态)
- 添加删除按钮的样式和禁用状态
- 完善处方单药品数量和总价的计算方法
---
.../components/tcm/tcmAdvice.vue | 194 +++++++++++++++++-
1 file changed, 192 insertions(+), 2 deletions(-)
diff --git a/openhis-ui-vue3/src/views/doctorstation/components/tcm/tcmAdvice.vue b/openhis-ui-vue3/src/views/doctorstation/components/tcm/tcmAdvice.vue
index 912b6e3a..6dd53e9a 100644
--- a/openhis-ui-vue3/src/views/doctorstation/components/tcm/tcmAdvice.vue
+++ b/openhis-ui-vue3/src/views/doctorstation/components/tcm/tcmAdvice.vue
@@ -13,10 +13,19 @@
>
+
+
+
- 药品数: {{ '1' }}种
- 总价: ¥ {{ 100 }}
+ 药品数: {{ getPrescriptionMedicineCount(index) }}种
+ 总价: ¥ {{ getPrescriptionTotalPrice(index) }}
@@ -660,6 +669,51 @@ function addNewPrescription(){
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); // 删除行会出现组号混乱的情况,所以这里重新更新标记
}
+// 判断处方单是否可删除
+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) {
prescriptionList.value[index].unitPrice = item.price;
// prescriptionList.value[index].lotNumber = item.lotNumber;
@@ -1599,6 +1684,90 @@ function validateGroups(saveList) {
}
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 });
@@ -1711,4 +1880,25 @@ defineExpose({ getListInfo, getDiagnosisInfo });
.add-icon:hover {
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;
+}
\ No newline at end of file