diff --git a/admin/src/views/tcm/diagnosis/index.vue b/admin/src/views/tcm/diagnosis/index.vue
index b5c7b8bb..7f7a3444 100644
--- a/admin/src/views/tcm/diagnosis/index.vue
+++ b/admin/src/views/tcm/diagnosis/index.vue
@@ -152,7 +152,7 @@
{{ row.gender_desc || '-' }} · {{ row.age ?? '-' }}岁
-
+
{{ appointmentStatusLabelByStatus(apt.status) }}
{{ apt.doctor_name || '-' }}
{{ apt.time_text || '-' }}
+
+
+ 取消挂号
+
+
@@ -304,7 +315,12 @@
视频二维码
二维码
- 取消挂号
+
+ 取消挂号
+
挂号日志
创建订单
删除
@@ -1408,13 +1424,29 @@ const appointmentCellClasses = (row: any) => {
const isAppointmentActiveForVideo = (row: any) =>
row.has_appointment && Number(row.appointment_status) === 1
-/** 已预约、已过号可取消(后端同步限制) */
+/** 已预约、已过号可取消(后端同步限制),针对行上主字段 */
const canCancelAppointmentRow = (row: any) => {
const s = Number(row.appointment_status)
return !!(row.has_appointment && row.appointment_id && (s === 1 || s === 4))
}
-// 取消挂号
+/** 单条挂号记录是否允许取消(已预约 1 / 已过号 4) */
+const canCancelAppointmentItem = (apt: any) => {
+ const s = Number(apt?.status)
+ return !!(apt?.id && (s === 1 || s === 4))
+}
+
+/**
+ * 「更多」里行级取消:仅当列表只展示一条挂号时可点,避免多条时与主键 appointment_id 不对齐
+ * 多条时在「挂号」列每条旁单独取消
+ */
+const canCancelAppointmentFromDropdown = (row: any) => {
+ if (!canCancelAppointmentRow(row)) return false
+ const rows = appointmentRows(row)
+ return rows.length <= 1
+}
+
+// 取消挂号(行级,唯一一条时)
const handleCancelAppointment = async (row: any) => {
if (!canCancelAppointmentRow(row)) {
const s = Number(row.appointment_status)
@@ -1425,9 +1457,39 @@ const handleCancelAppointment = async (row: any) => {
}
return
}
+ const rows = appointmentRows(row)
+ const target = rows.length === 1 ? rows[0] : null
+ const aptId = target?.id && canCancelAppointmentItem(target) ? target.id : row.appointment_id
try {
await feedback.confirm(`确定要取消患者「${row.patient_name}」的挂号吗?`)
- await cancelAppointment({ id: row.appointment_id })
+ await cancelAppointment({ id: aptId })
+ feedback.msgSuccess('取消挂号成功')
+ getLists()
+ fetchDateCounts()
+ if (guahaoLogDrawerVisible.value && guahaoLogContextRow.value?.id === row.id) {
+ await fetchGuahaoLogs(row.id)
+ }
+ } catch (e: any) {
+ if (e !== 'cancel') feedback.msgError(e?.msg || '取消挂号失败')
+ }
+}
+
+/** 取消指定挂号(多条展示时用) */
+const handleCancelAppointmentItem = async (row: any, apt: any) => {
+ if (!canCancelAppointmentItem(apt)) {
+ const s = Number(apt?.status)
+ if (s === 3) {
+ feedback.msgWarning('已完成就诊,无法取消挂号')
+ } else {
+ feedback.msgWarning('该挂号无法取消')
+ }
+ return
+ }
+ const doc = apt.doctor_name || '—'
+ const t = apt.time_text || '—'
+ try {
+ await feedback.confirm(`确定取消「${doc}」${t} 的挂号吗?(患者:${row.patient_name || '—'})`)
+ await cancelAppointment({ id: apt.id })
feedback.msgSuccess('取消挂号成功')
getLists()
fetchDateCounts()
@@ -2061,6 +2123,11 @@ onUnmounted(() => {
margin-top: 2px;
}
+ .apt-actions {
+ margin-top: 4px;
+ line-height: 1.2;
+ }
+
&.apt-item-active {
.apt-badge {
color: #3a4acc;