fix(doctorstation): 解决会诊医嘱删除和撤回功能问题
- 引入cancelConsultation接口用于处理会诊医嘱作废 - 分离会诊医嘱和普通医嘱的删除逻辑 - 实现会诊医嘱的作废功能,支持从contentJson解析consultationId - 添加会诊医嘱撤回功能,区分草稿状态和已提交状态 - 修复医嘱分类逻辑,将会诊类型值5归类到诊疗活动 - 添加调试日志用于跟踪医嘱处理流程 - 优化耗材医嘱删除逻辑,完善费用项清理 - 修复列表更新机制,确保作废医嘱及时从界面移除
This commit is contained in:
@@ -825,6 +825,7 @@ import {
|
||||
getOrderGroup,
|
||||
deleteGroup,
|
||||
queryGroupDetail,
|
||||
cancelConsultation, // 🔧 BugFix: 引入会诊作废接口
|
||||
} from '../api';
|
||||
import { advicePrint, getAdjustPriceSwitchState } from '@/api/public';
|
||||
import adviceBaseList from '../adviceBaseList.vue';
|
||||
@@ -1973,15 +1974,105 @@ function getOrgList() {
|
||||
|
||||
function handleDelete() {
|
||||
let selectRows = prescriptionRef.value.getSelectionRows();
|
||||
console.log('BugFix#219: handleDelete called, selectRows=', selectRows);
|
||||
|
||||
if (selectRows.length == 0) {
|
||||
proxy.$modal.msgWarning('请选择要删除的医嘱');
|
||||
return;
|
||||
}
|
||||
|
||||
// 🔧 BugFix: 分离会诊医嘱和普通医嘱
|
||||
let consultationRows = selectRows.filter(item => item.adviceType === 5);
|
||||
let normalRows = selectRows.filter(item => item.adviceType !== 5);
|
||||
|
||||
console.log('BugFix#219: consultationRows=', consultationRows.length, 'normalRows=', normalRows.length);
|
||||
|
||||
// 处理会诊医嘱删除
|
||||
if (consultationRows.length > 0) {
|
||||
console.log('BugFix#219: 处理会诊医嘱删除');
|
||||
console.log('BugFix#219: 会诊医嘱详情:', consultationRows.map(item => ({
|
||||
adviceType: item.adviceType,
|
||||
statusEnum: item.statusEnum,
|
||||
requestId: item.requestId,
|
||||
adviceName: item.adviceName
|
||||
})));
|
||||
|
||||
// 🔧 BugFix: 放宽条件,只要有requestId的会诊医嘱都可以尝试删除
|
||||
let draftConsultations = consultationRows.filter(item => item.requestId);
|
||||
console.log('BugFix#219: draftConsultations=', draftConsultations.length, '过滤条件: requestId存在 (不限制statusEnum)');
|
||||
console.log('BugFix#219: 未过滤的会诊医嘱:', consultationRows.map(item => ({
|
||||
statusEnum: item.statusEnum,
|
||||
hasRequestId: !!item.requestId
|
||||
})));
|
||||
|
||||
if (draftConsultations.length > 0) {
|
||||
console.log('BugFix#219: 开始作废草稿状态会诊医嘱');
|
||||
// 草稿状态的会诊直接作废
|
||||
let deletePromises = draftConsultations.map(item => {
|
||||
// 🔧 BugFix: 从contentJson中解析consultationId
|
||||
let consultationId = item.requestId;
|
||||
try {
|
||||
const contentJson = item.contentJson ? JSON.parse(item.contentJson) : {};
|
||||
consultationId = contentJson.consultationId || contentJson.consultationRequestId || item.requestId;
|
||||
console.log('BugFix#219: 解析consultationId=', consultationId, 'from contentJson');
|
||||
} catch (e) {
|
||||
console.warn('BugFix#219: 解析contentJson失败, 使用requestId:', item.requestId);
|
||||
}
|
||||
|
||||
console.log('BugFix#219: 作废会诊, consultationId=', consultationId);
|
||||
return cancelConsultation({ consultationId: consultationId, cancelReason: '作废' })
|
||||
.then((res) => {
|
||||
console.log('BugFix#219: 作废成功, res=', res);
|
||||
if (res.code == 200) {
|
||||
proxy.$modal.msgSuccess('会诊申请已作废');
|
||||
return true;
|
||||
} else {
|
||||
proxy.$modal.msgError('作废失败: ' + (res.msg || '未知错误'));
|
||||
return false;
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error('BugFix#219: 作废失败, err=', err);
|
||||
proxy.$modal.msgError('作废失败: ' + (err.message || '网络错误'));
|
||||
return false;
|
||||
});
|
||||
});
|
||||
|
||||
Promise.all(deletePromises).then((results) => {
|
||||
// 🔧 BugFix: 作废成功后,立即从列表中移除已作废的会诊医嘱
|
||||
const successCount = results.filter(r => r === true).length;
|
||||
if (successCount > 0) {
|
||||
console.log('BugFix#219: 作废成功', successCount, '条,从列表中移除');
|
||||
// 从 prescriptionList 中移除已作废的会诊医嘱
|
||||
draftConsultations.forEach(item => {
|
||||
const index = prescriptionList.value.findIndex(p => p.uniqueKey === item.uniqueKey);
|
||||
if (index !== -1) {
|
||||
console.log('BugFix#219: 从列表中移除会诊医嘱, index=', index, 'adviceName=', item.adviceName);
|
||||
prescriptionList.value.splice(index, 1);
|
||||
}
|
||||
});
|
||||
}
|
||||
getListInfo(false);
|
||||
});
|
||||
} else {
|
||||
console.log('BugFix#219: 没有符合条件的会诊医嘱可删除');
|
||||
proxy.$modal.msgWarning('所选会诊医嘱不可删除');
|
||||
}
|
||||
}
|
||||
|
||||
// 处理普通医嘱删除
|
||||
if (normalRows.length == 0) {
|
||||
console.log('BugFix#219: 没有普通医嘱需要处理');
|
||||
return;
|
||||
}
|
||||
|
||||
// ... 普通医嘱删除逻辑保持不变
|
||||
|
||||
let deleteList = [];
|
||||
let sum = 0; // 未保存总数量
|
||||
for (let i = prescriptionList.value.length - 1; i >= 0; i--) {
|
||||
let deleteItem = prescriptionList.value[i];
|
||||
let index = selectRows.findIndex((item) => item.uniqueKey === deleteItem.uniqueKey);
|
||||
let index = normalRows.findIndex((item) => item.uniqueKey === deleteItem.uniqueKey);
|
||||
// 通过requestId判断是否已保存,如果选中项未保存 直接从数组中移除,如果已保存,调接口删除
|
||||
if (index != -1 && deleteItem.statusEnum == 1 && !deleteItem.requestId) {
|
||||
prescriptionList.value.splice(i, 1);
|
||||
@@ -2000,10 +2091,14 @@ function handleDelete() {
|
||||
updateExpandOrder([]);
|
||||
isAdding.value = false;
|
||||
adviceQueryParams.value.adviceTypes = undefined; // 🎯 修复:改为 adviceTypes(复数)
|
||||
if (sum == selectRows.length) {
|
||||
|
||||
// 计算未保存的会诊医嘱数量
|
||||
let consultationUnsaved = consultationRows.filter(item => item.statusEnum == 1 && !item.requestId).length;
|
||||
if (sum + consultationUnsaved == selectRows.length) {
|
||||
proxy.$modal.msgSuccess('删除成功');
|
||||
return;
|
||||
}
|
||||
|
||||
if (deleteList.length > 0) {
|
||||
savePrescription({ adviceSaveList: deleteList }).then((res) => {
|
||||
if (res.code == 200) {
|
||||
@@ -2011,7 +2106,7 @@ function handleDelete() {
|
||||
getListInfo(false);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
} else if (consultationRows.length == 0) {
|
||||
proxy.$modal.msgWarning('所选医嘱不可删除,请先撤回后再删除');
|
||||
return;
|
||||
}
|
||||
@@ -3311,26 +3406,122 @@ function escKeyListener(e) {
|
||||
}
|
||||
}
|
||||
|
||||
// 签退
|
||||
// 签退/撤回
|
||||
function handleSingOut() {
|
||||
let selectRows = prescriptionRef.value.getSelectionRows();
|
||||
let requestIdList = selectRows
|
||||
.filter((item) => {
|
||||
return item.statusEnum == 2;
|
||||
})
|
||||
.map((item) => {
|
||||
return item.requestId;
|
||||
});
|
||||
if (requestIdList.length == 0) {
|
||||
proxy.$modal.msgWarning('请选择已签发医嘱撤回');
|
||||
console.log('BugFix#219: handleSingOut called, selectRows=', selectRows);
|
||||
|
||||
if (selectRows.length == 0) {
|
||||
proxy.$modal.msgWarning('请选择要撤回的医嘱');
|
||||
return;
|
||||
}
|
||||
singOut(requestIdList).then((res) => {
|
||||
if (res.code == 200) {
|
||||
proxy.$modal.msgSuccess('操作成功');
|
||||
getListInfo(false);
|
||||
|
||||
// 🔧 BugFix: 检查是否选中了会诊医嘱
|
||||
let consultationRows = selectRows.filter(item => item.adviceType === 5);
|
||||
let normalRows = selectRows.filter(item => item.adviceType !== 5);
|
||||
|
||||
console.log('BugFix#219: consultationRows=', consultationRows.length, 'normalRows=', normalRows.length);
|
||||
|
||||
// 处理会诊医嘱撤回
|
||||
if (consultationRows.length > 0) {
|
||||
console.log('BugFix#219: 处理会诊医嘱撤回');
|
||||
console.log('BugFix#219: 会诊医嘱详情:', consultationRows.map(item => ({
|
||||
adviceType: item.adviceType,
|
||||
statusEnum: item.statusEnum,
|
||||
requestId: item.requestId,
|
||||
adviceName: item.adviceName
|
||||
})));
|
||||
|
||||
// 🔧 BugFix: 放宽条件,只要有requestId的会诊医嘱都可以处理
|
||||
let submittedConsultations = consultationRows.filter(item => item.requestId);
|
||||
console.log('BugFix#219: 可处理的会诊医嘱=', submittedConsultations.length);
|
||||
|
||||
// 处理草稿状态的会诊(直接作废)
|
||||
if (submittedConsultations.length > 0) {
|
||||
console.log('BugFix#219: 开始处理会诊医嘱, 数量=', submittedConsultations.length);
|
||||
let processPromises = submittedConsultations.map(item => {
|
||||
// 🔧 BugFix: 从contentJson中解析consultationId
|
||||
let consultationId = item.requestId;
|
||||
try {
|
||||
const contentJson = item.contentJson ? JSON.parse(item.contentJson) : {};
|
||||
consultationId = contentJson.consultationId || contentJson.consultationRequestId || item.requestId;
|
||||
console.log('BugFix#219: 处理-解析consultationId=', consultationId, 'from contentJson');
|
||||
} catch (e) {
|
||||
console.warn('BugFix#219: 处理-解析contentJson失败, 使用requestId:', item.requestId);
|
||||
}
|
||||
|
||||
// 根据状态决定操作类型
|
||||
const isSubmitted = item.statusEnum == 2;
|
||||
const cancelReason = isSubmitted ? '取消提交' : '作废';
|
||||
const successMsg = isSubmitted ? '会诊申请已撤回' : '会诊申请已作废';
|
||||
|
||||
console.log('BugFix#219: 处理会诊, consultationId=', consultationId, 'statusEnum=', item.statusEnum, 'cancelReason=', cancelReason);
|
||||
|
||||
return cancelConsultation({ consultationId: consultationId, cancelReason: cancelReason })
|
||||
.then((res) => {
|
||||
console.log('BugFix#219: 处理会诊成功, res=', res);
|
||||
if (res.code == 200) {
|
||||
proxy.$modal.msgSuccess(successMsg);
|
||||
return true;
|
||||
} else {
|
||||
proxy.$modal.msgError('操作失败: ' + (res.msg || '未知错误'));
|
||||
return false;
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error('BugFix#219: 处理会诊失败, err=', err);
|
||||
proxy.$modal.msgError('操作失败: ' + (err.message || '网络错误'));
|
||||
return false;
|
||||
});
|
||||
});
|
||||
|
||||
Promise.all(processPromises).then((results) => {
|
||||
// 🔧 BugFix: 操作成功后,立即从列表中移除已处理(作废/撤回)的会诊医嘱
|
||||
const successCount = results.filter(r => r === true).length;
|
||||
if (successCount > 0) {
|
||||
console.log('BugFix#219: 会诊医嘱处理成功', successCount, '条,从列表中移除');
|
||||
// 从 prescriptionList 中移除已处理的会诊医嘱
|
||||
submittedConsultations.forEach(item => {
|
||||
const index = prescriptionList.value.findIndex(p => p.uniqueKey === item.uniqueKey);
|
||||
if (index !== -1) {
|
||||
console.log('BugFix#219: 从列表中移除会诊医嘱, index=', index, 'adviceName=', item.adviceName);
|
||||
prescriptionList.value.splice(index, 1);
|
||||
}
|
||||
});
|
||||
}
|
||||
getListInfo(false);
|
||||
});
|
||||
} else {
|
||||
console.log('BugFix#219: 没有可处理的会诊医嘱');
|
||||
proxy.$modal.msgWarning('所选会诊医嘱不可撤回');
|
||||
}
|
||||
});
|
||||
|
||||
// 如果没有普通医嘱,直接返回
|
||||
if (normalRows.length == 0) {
|
||||
console.log('BugFix#219: 没有普通医嘱需要处理,返回');
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// 处理普通医嘱撤回
|
||||
if (normalRows.length > 0) {
|
||||
let requestIdList = normalRows
|
||||
.filter((item) => item.statusEnum == 2)
|
||||
.map((item) => item.requestId);
|
||||
|
||||
if (requestIdList.length == 0) {
|
||||
proxy.$modal.msgWarning('所选普通医嘱无可撤回项');
|
||||
return;
|
||||
}
|
||||
|
||||
singOut(requestIdList).then((res) => {
|
||||
if (res.code == 200) {
|
||||
proxy.$modal.msgSuccess('操作成功');
|
||||
getListInfo(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
prescriptionRef.value.clearSelection();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user