维护换卡处理的查询
This commit is contained in:
94
openhis-ui-vue3/src/api/cardRenewal/api.js
Normal file
94
openhis-ui-vue3/src/api/cardRenewal/api.js
Normal file
@@ -0,0 +1,94 @@
|
||||
import request from '@/utils/request';
|
||||
|
||||
// 查询患者列表 - 更新为匹配后端实际路径
|
||||
export function getPatientList(query) {
|
||||
console.log('查询患者列表API被调用,参数:', query);
|
||||
|
||||
// 调整参数以匹配后端控制器的要求
|
||||
const backendParams = {
|
||||
patientName: query.patientName || '',
|
||||
idCard: query.idCard || '',
|
||||
phoneNumber: query.phoneNumber || '', // 添加phoneNumber参数
|
||||
cardNo: '' // 后端控制器中有cardNo参数,但前端没有,可以传空字符串
|
||||
};
|
||||
|
||||
console.log('调整后的后端参数:', backendParams);
|
||||
|
||||
// 实际API调用代码 - 使用后端实际路径
|
||||
return request({
|
||||
url: '/openhis/charge/patientCardRenewal/getPatientInfo',
|
||||
method: 'get',
|
||||
params: backendParams
|
||||
}).then(response => {
|
||||
console.log('API返回结果:', response);
|
||||
|
||||
// 转换后端返回格式以适应前端组件
|
||||
if (response && response.code === 200) {
|
||||
// 检查后端返回的数据结构
|
||||
if (Array.isArray(response.data)) {
|
||||
// 如果是数组,直接使用
|
||||
return {
|
||||
code: 200,
|
||||
msg: 'success',
|
||||
rows: response.data,
|
||||
total: response.data.length
|
||||
};
|
||||
} else if (response.data) {
|
||||
// 如果是单个对象,包装成数组
|
||||
return {
|
||||
code: 200,
|
||||
msg: 'success',
|
||||
rows: [response.data],
|
||||
total: 1
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// 默认返回空数据
|
||||
return {
|
||||
code: response?.code || 500,
|
||||
msg: response?.msg || '查询失败',
|
||||
rows: [],
|
||||
total: 0
|
||||
};
|
||||
}).catch(error => {
|
||||
console.error('查询患者列表API调用失败:', error);
|
||||
// API调用失败时返回空数据
|
||||
return {
|
||||
code: 500,
|
||||
msg: 'API调用失败',
|
||||
rows: [],
|
||||
total: 0
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
// 执行患者换卡
|
||||
export function renewPatientCard(data) {
|
||||
return request({
|
||||
url: '/cardRenewal/card/renewal',
|
||||
method: 'post',
|
||||
data: data
|
||||
}).catch(error => {
|
||||
console.error('换卡操作API调用失败:', error);
|
||||
return {
|
||||
code: 500,
|
||||
msg: 'API调用失败'
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
// 获取患者详细信息
|
||||
export function getPatientInfo(patientId) {
|
||||
return request({
|
||||
url: '/cardRenewal/patient/info/' + patientId,
|
||||
method: 'get'
|
||||
}).catch(error => {
|
||||
console.error('获取患者详细信息API调用失败:', error);
|
||||
return {
|
||||
code: 500,
|
||||
msg: 'API调用失败',
|
||||
data: {}
|
||||
};
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user