8.26 17:41

This commit is contained in:
zoujiandong
2025-08-26 17:41:57 +08:00
parent b6120d9a40
commit ef5b3fb59f
15 changed files with 1331 additions and 55 deletions
+471 -9
View File
@@ -20,7 +20,7 @@
</uni-nav-bar>
<!-- 消息列表区域 -->
<view class="message-list">
<view class="message-list" v-if="activeTab === 'message'">
<!-- 消息项 -->
<view class="message-item" @click="openMessage">
<view class="message-avatar">
@@ -46,11 +46,102 @@
</view>
</view>
<!-- 患者列表区域 -->
<view class="patient-list" v-if="activeTab === 'list'">
<!-- 特殊操作项 -->
<view class="special-actions">
<view class="action-item" @click="addNewPatient">
<view class="action-icon new-patient">
<uni-icons type="person" size="24" color="#ffffff"></uni-icons>
<uni-icons type="plus" size="16" color="#ffffff" style="position: absolute; right: 8rpx; bottom: 8rpx;"></uni-icons>
</view>
<text class="action-text">新的患者</text>
<uni-icons type="right" size="20" color="#999"></uni-icons>
</view>
<view class="action-item" @click="managePatientGroups">
<view class="action-icon group-icon">
<view class="grid-icon">
<view class="grid-item"></view>
<view class="grid-item"></view>
<view class="grid-item"></view>
<view class="grid-item"></view>
</view>
</view>
<text class="action-text">患者分组 (随访5人)</text>
<uni-icons type="right" size="20" color="#999"></uni-icons>
</view>
</view>
<view class="listbox">
<!-- 使用 up-index-list 索引组件,数据动态渲染 -->
<up-index-list :index-list="indexList" custom-nav-height="140rpx">
<template v-for="group in patientGroups" :key="group.letter">
<up-index-item >
<up-index-anchor :text="group.letter" />
<view class="group-section">
<view class="patient-item" v-for="item in group.items" :key="item.name" @click="openPatient(item.name)">
<template v-if="item.placeholder">
<view class="patient-avatar-placeholder">
<uni-icons type="person" size="32" color="#ffffff"></uni-icons>
</view>
</template>
<template v-else>
<image class="patient-avatar" :src="item.avatar" mode="aspectFill"></image>
</template>
<view class="patient-info">
<text class="patient-name">{{ item.name }}</text>
<view class="patient-badge" v-if="item.badge">
<text class="badge-text">{{ item.badge }}</text>
</view>
</view>
<view class="patient-status">
<uni-icons type="compose" size="20" color="#8B2316"></uni-icons>
<text class="follow-date">随访于{{ item.date }}</text>
</view>
</view>
</view>
</up-index-item>
</template>
</up-index-list>
</view>
</view>
<view class="plan" v-if="activeTab === 'plan'">
<empty></empty>
<!-- 悬浮添加按钮 -->
<view class="floating-add-btn" @click="showAddMenu">
<uni-icons type="plus" size="24" color="#ffffff"></uni-icons>
<text class="btn-text">添加</text>
</view>
<!-- 添加菜单弹窗 -->
<view class="add-menu-popup" v-if="showAddMenuFlag" @click="hideAddMenu">
<view class="menu-content" @click.stop>
<!-- 添加日程 -->
<view class="menu-item" @click="addSchedule">
<up-image :src="dayImg" width="34rpx" height="34rpx" ></up-image>
<text class="menu-text">添加日程</text>
</view>
<!-- 分割线 -->
<view class="menu-divider"></view>
<!-- 添加随访计划 -->
<view class="menu-item" @click="addFollowUpPlan">
<up-image :src="planImg" width="34rpx" height="34rpx" ></up-image>
<text class="menu-text">添加随访计划</text>
</view>
</view>
</view>
</view>
<!-- 底部标签栏 -->
<view class="tab-bar">
<view class="tab-item active" @click="switchTab('message')">
<text class="tab-text">患者消息</text>
<view class="tab-line"></view>
</view>
<view class="tab-item" @click="switchTab('list')">
<text class="tab-text">患者列表</text>
@@ -62,9 +153,12 @@
</view>
</template>
<script setup>
import { ref } from 'vue';
import { ref, getCurrentInstance } from 'vue';
import { onShow } from "@dcloudio/uni-app";
import dayImg from "@/static/visit_data11.png"
import planImg from "@/static/visitplan.png"
// 消息列表数据
const messageList = ref([
@@ -79,6 +173,82 @@
// 当前激活的标签
const activeTab = ref('message');
const letters = ref(['A','C','E','L']);
const activeLetter = ref('A');
const scrollIntoViewId = ref('');
let scrollingByClick = false;
// 控制添加菜单弹窗显示
const showAddMenuFlag = ref(false);
// 组件实例(用于 selectorQuery 作用域)
const { proxy } = getCurrentInstance();
// up-index-list 数据源(与当前示例分组一致)
const indexList = ref([]);
// 列表高度(像素):窗口高度 - 顶部导航(rpx转px) - 底部tab(约100rpx->px) - 操作区(约200rpx->px)
const groupsListHeight = ref(0);
const rpxToPx = (rpx) => {
const { screenWidth } = uni.getSystemInfoSync();
return Math.round((screenWidth / 750) * rpx);
};
const computeListHeight = () => {
const { windowHeight } = uni.getSystemInfoSync();
const reserved = rpxToPx(240); // 140rpx(nav) + 100rpx(tab) 近似
groupsListHeight.value = Math.max(0, windowHeight - reserved);
};
// 分组数据(可从接口返回后赋值)
const patientGroups = ref([]);
// 动态生成索引字母
const rebuildIndexList = () => {
indexList.value = patientGroups.value.map(g => g.letter);
};
// 生成模拟数据
const generateMockDate = () => {
const start = new Date(2019, 0, 1).getTime();
const end = new Date().getTime();
const d = new Date(start + Math.random() * (end - start));
const y = d.getFullYear();
const m = `${d.getMonth() + 1}`.padStart(2, '0');
const day = `${d.getDate()}`.padStart(2, '0');
return `${y}-${m}-${day}`;
};
const generateMockGroups = () => {
const lettersPool = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.split('');
const avatarSamples = ['/static/avatar-a.png','/static/avatar-l.png','/static/avatar-l2.png'];
const groups = [];
lettersPool.forEach((L) => {
// 随机产生0-3个患者
const count = Math.floor(Math.random() * 3);
if (count === 0) return;
const items = Array.from({length: count}).map((_, i) => {
const usePlaceholder = Math.random() < 0.4;
return {
name: `${L}患者${i+1}`,
avatar: usePlaceholder ? '' : avatarSamples[Math.floor(Math.random()*avatarSamples.length)],
placeholder: usePlaceholder,
badge: Math.random() < 0.2 ? 'GOOD' : '',
date: generateMockDate()
};
});
groups.push({ letter: L, items });
});
return groups;
};
// 加载模拟数据
const loadMockGroups = () => {
uni.showLoading({ title: '加载中' });
setTimeout(() => {
patientGroups.value = generateMockGroups();
rebuildIndexList();
uni.hideLoading();
}, 300);
};
// 返回上一页
const goBack = () => {
@@ -109,7 +279,7 @@
});
};
// 切换标签
// 切换标签
const switchTab = (tab) => {
activeTab.value = tab;
@@ -118,10 +288,7 @@
// 患者消息页面逻辑
break;
case 'list':
// 跳转到患者列表页面
uni.navigateTo({
url: '/pages_app/myPatient/myPatient'
});
// 显示患者列表
break;
case 'plan':
// 跳转到随访计划页面
@@ -133,9 +300,62 @@
}
};
// 添加新患者
const addNewPatient = () => {
uni.showToast({
title: '添加新患者',
icon: 'none'
});
};
// 管理患者分组
const managePatientGroups = () => {
uni.showToast({
title: '管理患者分组',
icon: 'none'
});
};
// 打开患者详情
const openPatient = (patientName) => {
uni.showToast({
title: `打开患者: ${patientName}`,
icon: 'none'
});
};
// 添加随访计划
const addFollowUpPlan = () => {
showAddMenuFlag.value = false;
uni.navigateTo({
url: '/pages_app/visit/visit'
});
};
// 添加日程
const addSchedule = () => {
uni.navigateTo({
url: '/pages_app/schedule/schedule'
});
};
// 显示添加菜单
const showAddMenu = () => {
showAddMenuFlag.value = true;
};
// 隐藏添加菜单
const hideAddMenu = () => {
showAddMenuFlag.value = false;
};
// 使用 up-index-list 后不再需要手动滚动联动逻辑
// 页面显示时加载数据
onShow(() => {
loadMessageList();
loadMockGroups();
computeListHeight();
});
// 加载消息列表
@@ -149,7 +369,8 @@
.content {
background-color: #f5f5f5;
min-height: 100vh;
}
}
// 导航栏右侧按钮样式
.nav-right {
@@ -286,4 +507,245 @@
}
}
}
// 患者列表样式
.patient-list {
height:calc(100vh - 265rpx);
display: flex;
flex-direction:column;
background-color: #ffffff;
margin-top: 20rpx;
position: relative;
.listbox{
flex:1;
padding-bottom: 100rpx;
}
.groups-scroll {
display: none;
}
.special-actions {
background-color: #ffffff;
border-bottom: 1rpx solid #f0f0f0;
.action-item {
display: flex;
align-items: center;
padding: 30rpx;
border-bottom: 1rpx solid #f0f0f0;
&:last-child {
border-bottom: none;
}
.action-icon {
width: 60rpx;
height: 60rpx;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
margin-right: 20rpx;
position: relative;
&.new-patient {
background-color: #8B2316;
}
&.group-icon {
background-color: #8B2316;
.grid-icon {
display: grid;
grid-template-columns: 1fr 1fr;
grid-template-rows: 1fr 1fr;
gap: 2rpx;
width: 32rpx;
height: 32rpx;
.grid-item {
background-color: #ffffff;
border-radius: 2rpx;
}
}
}
}
.action-text {
flex: 1;
font-size: 32rpx;
color: #333333;
}
}
}
.letter-index {
position: fixed;
right: 10rpx;
top: 50%;
transform: translateY(-50%);
background-color: rgba(255, 255, 255, 0.9);
border-radius: 20rpx;
padding: 10rpx 5rpx;
z-index: 999;
.letter-item {
padding: 8rpx 12rpx;
font-size: 24rpx;
color: #666666;
text-align: center;
border-radius: 10rpx;
&.active {
color: #8B2316;
font-weight: 600;
}
&:active {
background-color: #f0f0f0;
}
}
}
}
.group-section {
.group-header {
padding: 20rpx 30rpx;
background-color: #f8f8f8;
font-size: 36rpx;
color: #666666;
font-weight: bold;
}
.patient-item {
display: flex;
align-items: center;
padding: 30rpx 80rpx 20rpx 30rpx;
border-bottom: 1rpx solid #f0f0f0;
background-color: #ffffff;
&:last-child {
border-bottom: none;
}
.patient-avatar,
.patient-avatar-placeholder {
width: 80rpx;
height: 80rpx;
border-radius: 10rpx;
margin-right: 20rpx;
display: flex;
align-items: center;
justify-content: center;
}
.patient-avatar-placeholder {
background-color: #ff6b6b;
}
.patient-info {
flex: 1;
.patient-name {
font-size: 32rpx;
color: #333333;
font-weight: 500;
margin-bottom: 8rpx;
}
.patient-badge {
background-color: #d4a574;
border-radius: 20rpx;
padding: 4rpx 12rpx;
display: inline-block;
.badge-text {
font-size: 20rpx;
color: #ffffff;
font-weight: 500;
}
}
}
.patient-status {
display: flex;
align-items: center;
.follow-date {
font-size: 24rpx;
color: #666666;
margin-left: 10rpx;
}
}
}
}
.floating-add-btn {
position: fixed;
bottom: 140rpx; /* Adjust based on nav-bar height */
right: 30rpx;
background-color: #8B2316;
border-radius: 50%;
width: 100rpx;
height: 100rpx;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
z-index: 999;
box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.1);
.btn-text {
font-size: 20rpx;
color: #ffffff;
margin-top: 4rpx;
}
}
.add-menu-popup {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: rgba(0, 0, 0, 0);
display: flex;
align-items: center;
justify-content: center;
z-index: 1000;
}
.menu-content {
background-color: #ffffff;
border-radius: 20rpx;
box-shadow: 0 8rpx 24rpx rgba(0, 0, 0, 0.2);
width: 80%;
max-width: 400rpx;
overflow: hidden;
}
.menu-item {
display: flex;
align-items: center;
padding: 30rpx 40rpx;
border-bottom: 1rpx solid #f0f0f0;
&:last-child {
border-bottom: none;
}
.menu-text {
font-size: 32rpx;
color: #333333;
margin-left: 20rpx;
}
}
.menu-divider {
height: 1rpx;
background-color: #f0f0f0;
margin: 0 40rpx;
}
</style>