Files
xk-doctor-wx/subPackages/sub_reception/reception_list.vue
2026-03-06 13:59:22 +08:00

169 lines
3.4 KiB
Vue

<template>
<view class="reception-list-container">
<u-navbar class="navbar" :is-back="true" title="转接方" title-color="#000"></u-navbar>
<view class="list-content">
<!-- 患者列表 -->
<view class="patient-list" v-if="patientList.length > 0">
<view
class="patient-item"
v-for="(patient, index) in patientList"
:key="patient.id"
:class="{ 'active': activePatientId === patient.id }"
@click="selectPatient(patient)"
>
<view class="patient-info">
<text class="patient-name">{{ patient.name || '未知患者' }}</text>
<text class="patient-mobile">{{ patient.mobile || '' }}</text>
</view>
<view class="patient-status">
<u-tag
:text="getStatusText(patient.status)"
:type="getStatusType(patient.status)"
size="mini"
></u-tag>
</view>
</view>
</view>
<!-- 空状态 -->
<view class="empty-state" v-else>
<d-empty text="暂无转接方患者"></d-empty>
</view>
</view>
</view>
</template>
<script>
import { getPatientList } from '@/api/reception.js';
export default {
data() {
return {
patientList: [],
activePatientId: null,
loading: false
}
},
onLoad() {
this.loadPatientList();
},
onShow() {
// 每次显示时刷新列表
this.loadPatientList();
},
methods: {
// 加载患者列表
async loadPatientList() {
this.loading = true;
try {
const res = await getPatientList({ type: 1 });
this.patientList = res || [];
// 恢复之前选中的患者
const savedId = uni.getStorageSync('doctorReceptionWx-id');
if (savedId) {
const patient = this.patientList.find(p => p.id === parseInt(savedId));
if (patient) {
this.selectPatient(patient);
}
}
} catch (error) {
console.error('加载患者列表失败:', error);
uni.showToast({
title: '加载失败',
icon: 'none'
});
} finally {
this.loading = false;
}
},
// 选择患者
selectPatient(patient) {
this.activePatientId = patient.id;
// 保存当前选中的患者ID
uni.setStorageSync('doctorReceptionWx-id', patient.id.toString());
// 跳转到聊天室
uni.navigateTo({
url: `/subPackages/sub_reception/reception_chat?register_id=${patient.id}&room_id=${patient.room_id || ''}&patient_name=${patient.name || ''}`
});
},
// 获取状态文本
getStatusText(status) {
const statusMap = {
0: '待接诊',
1: '问诊中',
2: '已结束'
};
return statusMap[status] || '未知';
},
// 获取状态类型
getStatusType(status) {
const typeMap = {
0: 'warning',
1: 'success',
2: 'info'
};
return typeMap[status] || 'info';
}
}
}
</script>
<style lang="scss" scoped>
.reception-list-container {
background-color: #f7f8fa;
min-height: 100vh;
}
.list-content {
padding: 20rpx;
}
.patient-list {
.patient-item {
background-color: #fff;
border-radius: 16rpx;
padding: 30rpx;
margin-bottom: 20rpx;
display: flex;
justify-content: space-between;
align-items: center;
&.active {
border: 2rpx solid #6ACDBB;
}
.patient-info {
display: flex;
flex-direction: column;
.patient-name {
font-size: 32rpx;
font-weight: 500;
color: #333;
margin-bottom: 10rpx;
}
.patient-mobile {
font-size: 28rpx;
color: #999;
}
}
.patient-status {
margin-left: 20rpx;
}
}
}
.empty-state {
padding: 100rpx 0;
text-align: center;
}
</style>