From d99157343dce82d2329ed9495685a2d66c9fe9de Mon Sep 17 00:00:00 2001 From: hejiafeng2003 <14455358+hejiafeng2003@user.noreply.gitee.com> Date: Mon, 23 Dec 2024 01:42:39 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E4=BF=AE=E5=A4=8D=E7=97=85=E5=8E=86?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E6=98=BE=E7=A4=BA=E9=97=AE=E9=A2=98=202?= =?UTF-8?q?=E3=80=81=E5=AE=9E=E7=8E=B0=E7=99=BB=E5=BD=95=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E7=BE=8E=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/medical.js | 60 ++++++++++++----- src/views/login/Index.vue | 125 ++++++++++++++++++++++++------------ src/views/medical/Query.vue | 12 ++-- 3 files changed, 136 insertions(+), 61 deletions(-) diff --git a/src/api/medical.js b/src/api/medical.js index e6f4b16..2f58b3d 100644 --- a/src/api/medical.js +++ b/src/api/medical.js @@ -4,32 +4,62 @@ const BASE_URL = '/api/medical-records'; export const medicalApi = { // 创建病历 - createRecord(record) { - return axiosInstance.post(BASE_URL, record) + async createRecord(record) { + try { + const response = await axiosInstance.post(BASE_URL, record); + return response.data; // 返回响应数据 + } catch (error) { + console.error('创建病历失败:', error); + throw new Error(error.response?.data?.message || '创建病历失败'); // 抛出错误 + } }, // 获取所有病历 - getAllRecords(patientName = '') { - - return axiosInstance.get(BASE_URL, { - params: { - patientName - } - }) + async getAllRecords(patientName = '') { + try { + const response = await axiosInstance.get(BASE_URL, { + params: { + patientName + } + }); + console.log('111获取所有病历的响应:', response); // 打印响应 + console.log('222获取所有病历的响应:', response.data); // 打印响应 + return response ; // 返回响应数据 + } catch (error) { + console.error('获取病历失败:', error); + throw new Error(error.response?.data?.message || '获取病历失败'); // 抛出错误 + } }, // 获取单个病历 - getRecord(id) { - return axiosInstance.get(`${BASE_URL}/${id}`) + async getRecord(id) { + try { + const response = await axiosInstance.get(`${BASE_URL}/${id}`); + return response.data; // 返回响应数据 + } catch (error) { + console.error('获取病历失败:', error); + throw new Error(error.response?.data?.message || '获取病历失败'); // 抛出错误 + } }, // 更新病历 - updateRecord(id, record) { - return axiosInstance.put(`${BASE_URL}/${id}`, record) + async updateRecord(id, record) { + try { + const response = await axiosInstance.put(`${BASE_URL}/${id}`, record); + return response.data; // 返回响应数据 + } catch (error) { + console.error('更新病历失败:', error); + throw new Error(error.response?.data?.message || '更新病历失败'); // 抛出错误 + } }, // 删除病历 - deleteRecord(id) { - return axiosInstance.delete(`${BASE_URL}/${id}`) + async deleteRecord(id) { + try { + await axiosInstance.delete(`${BASE_URL}/${id}`); + } catch (error) { + console.error('删除病历失败:', error); + throw new Error(error.response?.data?.message || '删除病历失败'); // 抛出错误 + } } } diff --git a/src/views/login/Index.vue b/src/views/login/Index.vue index e932f20..6eba87e 100644 --- a/src/views/login/Index.vue +++ b/src/views/login/Index.vue @@ -1,18 +1,21 @@