194 lines
6.1 KiB
Markdown
194 lines
6.1 KiB
Markdown
# getAppDoctor方法修改说明
|
||
|
||
## 🎯 修改目标
|
||
|
||
1. 修改后端 `getAppDoctor` 方法,不再将医院信息存储到数据库
|
||
2. 处理返回的医生列表数据(之前是单个对象,现在是列表)
|
||
3. 更新前端代码,支持从多个医生中选择
|
||
4. 确保找到医生信息后,医院名称数据能正确展示
|
||
|
||
## 🔧 后端修改内容
|
||
|
||
### 1. 修改 `CaseClinicalDoctorService.java`
|
||
|
||
#### 主要变化:
|
||
- **返回类型**: 从 `ResponseDTO<AppDoctorVO>` 改为 `ResponseDTO<List<AppDoctorVO>>`
|
||
- **医院信息处理**: 不再存储到数据库,只获取并返回
|
||
- **列表处理**: 遍历返回的医生列表,为每个医生创建VO对象
|
||
|
||
#### 具体修改:
|
||
```java
|
||
// 修改前
|
||
public ResponseDTO<AppDoctorVO> getAppDoctor(String doctorName)
|
||
|
||
// 修改后
|
||
public ResponseDTO<List<AppDoctorVO>> getAppDoctor(String doctorName)
|
||
```
|
||
|
||
#### 医院信息处理逻辑:
|
||
```java
|
||
// 修改前:查询数据库并存储
|
||
if (existingHospital != null) {
|
||
appDoctor.setHospitalId(existingHospital.getHospitalId());
|
||
appDoctor.setHospitalName(existingHospital.getHospitalName());
|
||
} else {
|
||
// 创建新的医院实体并插入数据库
|
||
BasicHospitalEntity newHospital = new BasicHospitalEntity();
|
||
// ... 设置医院信息
|
||
basicHospitalDao.insert(newHospital);
|
||
appDoctor.setHospitalId(newHospital.getHospitalId());
|
||
appDoctor.setHospitalName(newHospital.getHospitalName());
|
||
}
|
||
|
||
// 修改后:只获取信息,不存储
|
||
if (hospitalResponse != null && hospitalResponse.getData() != null) {
|
||
GetHospitalByUuidResponse.GetHospitalByUuidData hospitalData = hospitalResponse.getData();
|
||
appDoctor.setHospitalName(hospitalData.getName());
|
||
}
|
||
```
|
||
|
||
## 🎨 前端修改内容
|
||
|
||
### 1. 修改 `case-clinical-doctor-form.vue`
|
||
|
||
#### 新增功能:
|
||
- **医生选择对话框**: 当搜索到多个医生时,显示选择对话框
|
||
- **列表展示**: 显示医生姓名、手机号、省份、医院等信息
|
||
- **智能选择**: 只有一个结果时自动选择,多个结果时用户手动选择
|
||
- **医院名称显示**: 在医生信息提示和医院选择区域显示医生所在医院
|
||
|
||
#### 新增变量:
|
||
```javascript
|
||
const doctorSelectionVisible = ref(false); // 医生选择对话框显示状态
|
||
const doctorSelectionList = ref([]); // 医生选择列表
|
||
```
|
||
|
||
#### 新增函数:
|
||
```javascript
|
||
// 显示医生选择对话框
|
||
function showDoctorSelectionModal(doctorList) {
|
||
doctorSelectionList.value = doctorList;
|
||
doctorSelectionVisible.value = true;
|
||
}
|
||
|
||
// 关闭医生选择对话框
|
||
function closeDoctorSelectionModal() {
|
||
doctorSelectionVisible.value = false;
|
||
doctorSelectionList.value = [];
|
||
}
|
||
|
||
// 选择医生
|
||
function selectDoctor(doctor) {
|
||
appDoctorInfo.value = doctor;
|
||
closeDoctorSelectionModal();
|
||
message.info('已选择医生,请确认是否使用此信息');
|
||
}
|
||
```
|
||
|
||
#### 修改搜索逻辑:
|
||
```javascript
|
||
// 修改前:直接使用返回数据
|
||
if (result.data) {
|
||
appDoctorInfo.value = result.data;
|
||
message.info('找到APP医生信息,请确认是否使用');
|
||
}
|
||
|
||
// 修改后:处理列表数据
|
||
if (result.data && Array.isArray(result.data) && result.data.length > 0) {
|
||
if (result.data.length === 1) {
|
||
// 只有一个结果,直接使用
|
||
appDoctorInfo.value = result.data[0];
|
||
message.info('找到APP医生信息,请确认是否使用');
|
||
} else {
|
||
// 多个结果,显示选择对话框
|
||
showDoctorSelectionModal(result.data);
|
||
}
|
||
}
|
||
```
|
||
|
||
#### 医院名称显示逻辑:
|
||
```javascript
|
||
// 医生信息提示中显示医院名称
|
||
:description="`手机号:${appDoctorInfo.phone || '未知'} | 省份:${appDoctorInfo.province || '未知'}${appDoctorInfo.hospitalName ? ' | 医院:' + appDoctorInfo.hospitalName : ''}`"
|
||
|
||
// 医院选择区域显示医生所在医院
|
||
<div v-if="form.hospitalName && !form.doctorId" style="margin-bottom: 8px;">
|
||
<a-alert
|
||
:message="`医生所在医院:${form.hospitalName}`"
|
||
type="success"
|
||
show-icon
|
||
closable
|
||
@close="form.hospitalName = undefined"
|
||
/>
|
||
</div>
|
||
```
|
||
|
||
#### 新增UI组件:
|
||
```html
|
||
<!-- 医生选择对话框 -->
|
||
<a-modal
|
||
title="选择医生"
|
||
:open="doctorSelectionVisible"
|
||
@cancel="closeDoctorSelectionModal"
|
||
:maskClosable="false"
|
||
:destroyOnClose="true"
|
||
width="600px"
|
||
>
|
||
<div class="doctor-selection-list">
|
||
<a-list :data-source="doctorSelectionList" item-layout="horizontal">
|
||
<!-- 医生信息展示 -->
|
||
</a-list>
|
||
</div>
|
||
</a-modal>
|
||
```
|
||
|
||
## 📋 修改检查清单
|
||
|
||
### 后端修改:
|
||
- [x] 修改返回类型为 `List<AppDoctorVO>`
|
||
- [x] 移除医院信息存储逻辑
|
||
- [x] 添加列表遍历处理
|
||
- [x] 添加必要的import语句
|
||
|
||
### 前端修改:
|
||
- [x] 修改搜索逻辑处理列表数据
|
||
- [x] 添加医生选择对话框
|
||
- [x] 添加相关状态变量
|
||
- [x] 添加选择处理函数
|
||
- [x] 添加样式美化
|
||
|
||
## 🚀 使用方法
|
||
|
||
### 1. 搜索医生
|
||
- 在医生姓名输入框中输入姓名
|
||
- 点击搜索按钮或按回车键
|
||
|
||
### 2. 处理搜索结果
|
||
- **单个结果**: 自动显示医生信息,用户确认后使用
|
||
- **多个结果**: 显示选择对话框,用户手动选择
|
||
|
||
### 3. 选择医生
|
||
- 在选择对话框中查看医生详细信息
|
||
- 点击"选择此医生"按钮确认选择
|
||
|
||
### 4. 医院信息显示
|
||
- **医生信息提示**: 显示医生姓名、手机号、省份、医院名称
|
||
- **医院选择区域**: 在所属医院字段上方显示医生所在医院
|
||
- **手动选择**: 用户需要手动选择对应的医院(不自动设置)
|
||
|
||
## ⚠️ 注意事项
|
||
|
||
1. **数据一致性**: 后端不再存储医院信息,每次查询都是实时获取
|
||
2. **性能考虑**: 多个医生时会有多次API调用获取医院信息
|
||
3. **错误处理**: 如果医院信息获取失败,医生信息仍然可用
|
||
4. **用户体验**: 多个结果时用户需要手动选择,增加了操作步骤
|
||
|
||
## ✅ 完成状态
|
||
|
||
- [x] 后端 `getAppDoctor` 方法修改完成
|
||
- [x] 前端医生选择对话框添加完成
|
||
- [x] 列表数据处理逻辑完成
|
||
- [x] 样式美化完成
|
||
- [x] 文档说明完成
|
||
|
||
**所有修改已完成!** 现在系统支持从多个医生中选择,并且不再将医院信息存储到数据库。 |