From 5548b8c1c50947c862c85d0c4048459a39482d3b Mon Sep 17 00:00:00 2001
From: zhangchen <1652267879@qq.com>
Date: 星期五, 12 九月 2025 15:03:34 +0800
Subject: [PATCH] ID1766-修改患者样式

---
 src/views/mobile/bedsideAuxiliaryScreen/components/Header.vue |   61 +++++++++++++++++++++++++++---
 1 files changed, 54 insertions(+), 7 deletions(-)

diff --git a/src/views/mobile/bedsideAuxiliaryScreen/components/Header.vue b/src/views/mobile/bedsideAuxiliaryScreen/components/Header.vue
index 4df3652..ab1b54d 100644
--- a/src/views/mobile/bedsideAuxiliaryScreen/components/Header.vue
+++ b/src/views/mobile/bedsideAuxiliaryScreen/components/Header.vue
@@ -23,7 +23,8 @@
         <!-- 有排班 -->
         <template v-else>
           <span class="info-text">{{ patientInfo.patientName }}</span>
-          <span class="info-text">{{ patientInfo.age }}岁</span>
+          <span v-if="isShowBirthDate" class="info-text">{{ patientInfo.birthDate }}</span>
+          <span v-else class="info-text">{{ patientInfo.age }}岁</span>
           <span class="info-text">{{ patientInfo.gender }}</span>
           <span v-if="patientInfo.patFormNumber" class="info-text">
             {{ patientInfo.patForm }}:{{ patientInfo.patFormNumber }}</span
@@ -64,7 +65,8 @@
         alt=""
         @click="openSettingDeviceDialog"
       />
-      <img :src="userImg" class="btn-img" alt="" @click="openLoginDialog" />
+      <img v-if="userInfo?.code" :src="userInfo?.userAvatar" class="btn-img" alt="" @click="openLoginDialog" />
+      <img v-else :src="userImg" class="btn-img" alt="" @click="openLoginDialog" />
     </div>
   </div>
   <!-- 设置设备编号组件 -->
@@ -73,6 +75,8 @@
   <ScheduledTaskDialog ref="scheduledTaskDialogRef" />
   <!-- 定时任务提醒组件 -->
   <TaskAlert ref="taskAlertRef" @close="taskAlaetClose" />
+  <!-- 用户登录组件 -->
+  <LoginDialog ref="loginDialogRef" />
 </template>
 
 <script lang="ts" setup name="Header">
@@ -93,6 +97,7 @@
   () => import("./ScheduledTask.vue")
 );
 const TaskAlert = defineAsyncComponent(() => import("./TaskAlart.vue"));
+const LoginDialog = defineAsyncComponent(() => import('./Login/index.vue'));
 
 import atRegularTimeImg from "../../../../img/dingshi.png";
 import setUpImg from "../../../../img/shezhi.png";
@@ -101,6 +106,7 @@
 import { useBedsideAuxiliaryScreenStore } from "@/store/bedsideAuxiliaryScreen";
 import { EPatForm, EPageType } from "@/store/type/bedsideAuxiliaryScreen.type";
 import { ElMessage } from "element-plus";
+import { maskName } from '@/utils/utils';
 
 const bedsideAuxiliaryScreenStore = useBedsideAuxiliaryScreenStore();
 
@@ -110,6 +116,7 @@
 const settingDeviceDialogRef = ref<any>(null);
 const scheduledTaskDialogRef = ref<any>(null);
 const taskAlertRef = ref<any>(null);
+const loginDialogRef = ref<any>(null);
 
 const countdown = ref(null); // 定时任务的倒计时
 const isTaskAlartIsOpen = ref(false); // 定时任务的提醒弹框是否显示
@@ -118,9 +125,10 @@
   return bedsideAuxiliaryScreenStore.deviceData.pageType;
 });
 
+
 const patientInfo = computed(() => {
   return {
-    patientName: bedsideAuxiliaryScreenStore.deviceData.patientName,
+    patientName: bedsideAuxiliaryScreenStore.deviceData.customConfiguration.患者信息是否加密显示 === 1 ? maskName(bedsideAuxiliaryScreenStore.deviceData.patientName) :  bedsideAuxiliaryScreenStore.deviceData.patientName,
     patientPhone: bedsideAuxiliaryScreenStore.deviceData.patientPhone,
     age: bedsideAuxiliaryScreenStore.deviceData.age,
     gender: bedsideAuxiliaryScreenStore.deviceData.gender,
@@ -136,7 +144,12 @@
           bedsideAuxiliaryScreenStore.deviceData.underTreatment.dialysisAge
         )
       : null,
+    birthDate: bedsideAuxiliaryScreenStore.deviceData.患者出生日期,
   };
+});
+
+const isShowBirthDate = computed(() => {
+  return bedsideAuxiliaryScreenStore.deviceData.customConfiguration.是否显示患者出生年月日 === 1;
 });
 
 const formattedCountdown = computed(() => {
@@ -150,6 +163,14 @@
   } else {
     return `${seconds}s`;
   }
+});
+
+
+const userInfo = computed(() => {
+  if (!bedsideAuxiliaryScreenStore.userInfo) return null
+  return Object.assign({}, bedsideAuxiliaryScreenStore.userInfo, {
+    userAvatar: bedsideAuxiliaryScreenStore.userInfo?.userAvatar ? bedsideAuxiliaryScreenStore.userInfo?.userAvatar : generateCircularAvatar(bedsideAuxiliaryScreenStore.userInfo?.userName)
+  });
 });
 
 watch(
@@ -226,12 +247,38 @@
 };
 
 const openLoginDialog = () => {
-  ElMessage({
-    message: "功能开发中,敬请期待!",
-    type: "warning",
-  });
+  if (
+    !bedsideAuxiliaryScreenStore.deviceCode ||
+    !bedsideAuxiliaryScreenStore.deviceData.deviceCode
+  )
+    return ElMessage.warning("未初始化或正在进行初始化操作中");
+    console.log(loginDialogRef)
+    loginDialogRef.value.openDialog();
 };
 
+function generateCircularAvatar(name: string, size = 100): string {
+  console.log('name: ', name)
+  const canvas = document.createElement('canvas');
+  canvas.width = size;
+  canvas.height = size;
+  const ctx = canvas.getContext('2d')!;
+  
+  // 绘制圆形背景
+  ctx.fillStyle = '#dae5ec';
+  ctx.beginPath();
+  ctx.arc(size / 2, size / 2, size / 2, 0, Math.PI * 2);
+  ctx.fill();
+  
+  // 绘制文字(第一个字)
+  ctx.fillStyle = '#70a3dd'; // 字体颜色
+  ctx.font = `${size * 0.5}px sans-serif`; // 字体大小为头像大小的一半
+  ctx.textAlign = 'center';
+  ctx.textBaseline = 'middle';
+  ctx.fillText(name.charAt(0), size / 2, size / 2);
+  
+  return canvas.toDataURL('image/png'); // 返回 Base64 图片
+}
+
 onUnmounted(() => {
   clearTimer();
 });

--
Gitblit v1.8.0