feat(medications): 添加药品详情页面和删除功能

新增药品详情页面,支持查看药品信息、编辑备注、切换提醒状态和删除药品
- 创建动态路由页面 /medications/[medicationId].tsx 展示药品详细信息
- 添加语音输入备注功能,支持 iOS 语音识别
- 实现药品删除确认对话框和删除操作
- 优化药品卡片点击跳转详情页面的交互
- 添加删除操作的加载状态和错误处理
- 改进药品管理页面的开关状态显示和加载指示器
This commit is contained in:
richarjiang
2025-11-10 14:46:13 +08:00
parent 25b8e45af8
commit 0594831c9f
6 changed files with 1375 additions and 46 deletions

View File

@@ -498,18 +498,25 @@ const medicationsSlice = createSlice({
// ==================== deleteMedication ====================
builder
.addCase(deleteMedicationAction.pending, (state) => {
console.log('[MEDICATIONS_SLICE] Delete operation pending');
state.loading.delete = true;
state.error = null;
})
.addCase(deleteMedicationAction.fulfilled, (state, action) => {
console.log('[MEDICATIONS_SLICE] Delete operation fulfilled', { deletedId: action.payload });
state.loading.delete = false;
const deletedId = action.payload;
state.medications = state.medications.filter((m) => m.id !== deletedId);
state.activeMedications = state.activeMedications.filter(
(m) => m.id !== deletedId
);
console.log('[MEDICATIONS_SLICE] Medications after delete', {
totalMedications: state.medications.length,
activeMedications: state.activeMedications.length
});
})
.addCase(deleteMedicationAction.rejected, (state, action) => {
console.log('[MEDICATIONS_SLICE] Delete operation rejected', action.error);
state.loading.delete = false;
state.error = action.error.message || '删除药物失败';
});