This commit is contained in:
Your Name
2026-04-22 16:36:40 +08:00
parent 4872e4d2e6
commit 852bcd54a5
7 changed files with 528 additions and 66 deletions
+58 -30
View File
@@ -5,7 +5,7 @@
:title="drawerTitle"
size="60%"
:before-close="handleClose"
:z-index="1500"
:z-index="viewOnly ? 4000 : 1500"
:modal="true"
class="diagnosis-drawer"
>
@@ -18,6 +18,10 @@
:rules="formRules"
label-width="160px"
>
<fieldset
:disabled="viewOnly"
class="diagnosis-view-fieldset border-0 min-w-0 p-0 m-0"
>
<!-- 基本信息 -->
<el-divider content-position="left">基本信息</el-divider>
@@ -520,6 +524,7 @@
placeholder="请输入病史补充"
/>
</el-form-item>
</fieldset>
</el-form>
</el-tab-pane>
@@ -664,11 +669,11 @@
<template #footer>
<div class="flex justify-end gap-3 px-4 pb-4">
<el-button @click="handleClose">取消</el-button>
<el-button
v-if="activeTab === 'basic'"
type="primary"
@click="handleSubmit"
<el-button @click="handleClose">{{ viewOnly ? '关闭' : '取消' }}</el-button>
<el-button
v-if="!viewOnly && activeTab === 'basic'"
type="primary"
@click="handleSubmit"
:loading="submitting"
>
确定
@@ -711,6 +716,8 @@ const callRecordPanelRef = ref<{ refresh?: () => void } | null>(null)
const prescriptionRef = ref()
const visible = ref(false)
/** 只读查看:与 consumers 处方等处「查看诊单」一致,全部 Tab 仅展示不可保存 */
const viewOnly = ref(false)
const formRef = ref()
const mode = ref('add')
const submitting = ref(false)
@@ -721,7 +728,10 @@ const hasPhonePlainPermission = computed(() => hasPermission(['tcm.diagnosis/pho
const showPhoneMaskedEdit = computed(() => mode.value === 'edit' && !hasPhonePlainPermission.value)
const phoneRevealUnlocked = ref(false)
const activeTab = ref('basic')
const drawerTitle = computed(() => (mode.value === 'add' ? '新增诊单' : '编辑诊单'))
const drawerTitle = computed(() => {
if (viewOnly.value) return '诊单详情'
return mode.value === 'add' ? '新增诊单' : '编辑诊单'
})
watch([visible, activeTab], () => {
if (!visible.value) return
@@ -1075,7 +1085,22 @@ const getDictOptions = async () => {
}
}
async function loadDiagnosisDetailIntoForm(id: number): Promise<void> {
const data = await tcmDiagnosisDetail({ id })
originalPhone.value = data.phone || ''
originalIdCard.value = data.id_card || ''
data.phone = hasPhonePlainPermission.value ? data.phone || '' : maskPhone(data.phone || '')
data.id_card = maskIdCard(data.id_card || '')
formData.value = data
const y = data.diabetes_discovery_year
formData.value.diabetes_discovery_year = y == null || y === '' ? '' : String(y)
}
const open = async (type: string, id?: number) => {
viewOnly.value = false
mode.value = type
visible.value = true
activeTab.value = 'basic' // 重置到基本信息标签页
@@ -1085,27 +1110,27 @@ const open = async (type: string, id?: number) => {
await getDictOptions()
if (type === 'edit' && id) {
const data = await tcmDiagnosisDetail({ id })
// 保存原始完整数据
originalPhone.value = data.phone || ''
originalIdCard.value = data.id_card || ''
// 有「手机号明文」权限:表单中保持完整号码;否则表单内为脱敏(编辑无权限时用只读区+点击展开)
data.phone = hasPhonePlainPermission.value ? data.phone || '' : maskPhone(data.phone || '')
data.id_card = maskIdCard(data.id_card || '')
formData.value = data
const y = data.diabetes_discovery_year
formData.value.diabetes_discovery_year =
y == null || y === '' ? '' : String(y)
await loadDiagnosisDetailIntoForm(id)
} else if (type === 'add') {
const userStore = useUserStore()
formData.value.assistant_id = userStore.userInfo?.id || ''
}
}
/** 只读打开:与编辑同一套界面与全部 Tab,不可保存 */
const openViewOnly = async (id: number) => {
if (!id) return
viewOnly.value = true
mode.value = 'edit'
visible.value = true
activeTab.value = 'basic'
phoneRevealUnlocked.value = false
await getDictOptions()
await loadDiagnosisDetailIntoForm(id)
}
const handleSubmit = async () => {
if (viewOnly.value) return
await formRef.value?.validate()
submitting.value = true
@@ -1239,12 +1264,14 @@ const handleClose = () => {
isPhoneFocused.value = false
isIdCardFocused.value = false
phoneRevealUnlocked.value = false
viewOnly.value = false
visible.value = false
}
defineExpose({
open,
openViewOnly,
refreshCaseList: () => caseRecordListRef.value?.refresh?.()
})
</script>
@@ -1252,7 +1279,15 @@ defineExpose({
<style lang="scss" scoped>
.edit-drawer {
font-size: 12px;
.diagnosis-view-fieldset:disabled {
opacity: 1;
:deep(.el-input__wrapper),
:deep(.el-textarea__inner) {
box-shadow: none;
}
}
:deep(.el-form) {
padding-bottom: 20px;
font-size: 12px;
@@ -1415,14 +1450,7 @@ defineExpose({
z-index: 3000 !important;
}
/* 降低抽屉及其遮罩层的z-index */
.el-drawer {
z-index: 1500 !important;
}
.el-overlay {
z-index: 1499 ;
}
/* 勿对全局 .el-drawer / .el-overlay 写 z-index,会覆盖子组件的 :z-index(例如从消费处方里嵌套打开只读诊单时会被压在下面) */
/* 确保日期选择器和下拉选择器的弹出层在最上层 */
.el-picker__popper,