fix bug525:[手术管理-门诊手术安排-计费] 已勾选“待签发”项目且未收费,点击“删除”提示“只能删除待签发且未收费的项目”
This commit is contained in:
@@ -873,6 +873,32 @@ function ensureOrgTreeLoaded() {
|
||||
});
|
||||
}
|
||||
|
||||
/** 待签发且未收费(chargeStatus=5 为已收费) */
|
||||
function isPendingUnsignedAndUnpaid(item) {
|
||||
return item.statusEnum == 1 && item.chargeStatus != 5
|
||||
}
|
||||
|
||||
/**
|
||||
* 门诊划价:仅允许操作本人开立(bizRequestFlag==1 或空)。
|
||||
* 手术计费:列表接口需按库中 generate_source_enum 查询(当前多为 1),故子组件仍传 generateSourceEnum=1;
|
||||
* 通过 patientInfo.generateSourceEnum===6(手术计费在 chargePatientInfo 中已写入)识别场景,删除时不卡 bizRequestFlag。
|
||||
*/
|
||||
function isSurgeryChargeBillingContext() {
|
||||
const fromPatient = props.patientInfo?.generateSourceEnum
|
||||
return fromPatient != null && Number(fromPatient) === 6
|
||||
}
|
||||
|
||||
function isBizRequestAllowedForDelete(item) {
|
||||
if (isSurgeryChargeBillingContext()) {
|
||||
return true
|
||||
}
|
||||
const src = props.generateSourceEnum != null ? Number(props.generateSourceEnum) : NaN
|
||||
if (src === 6) {
|
||||
return true
|
||||
}
|
||||
return Number(item.bizRequestFlag) === 1 || !item.bizRequestFlag
|
||||
}
|
||||
|
||||
function handleDelete() {
|
||||
// 🔧 修复:使用 groupIndexList 而不是 check 属性
|
||||
// 因为 watch 监听器会在数据更新时重置 check 为 false
|
||||
@@ -881,80 +907,93 @@ function handleDelete() {
|
||||
return;
|
||||
}
|
||||
|
||||
let deleteList = groupIndexList.value.map((index) => {
|
||||
const item = prescriptionList.value[index];
|
||||
// 只删除待签发且未收费的项目
|
||||
if (item.statusEnum != 1 || item.chargeStatus == 5) {
|
||||
return null;
|
||||
}
|
||||
// 🔧 Bug #442: 非本人创建的医嘱不允许删除(与签发/签退逻辑保持一致)
|
||||
if (Number(item.bizRequestFlag) !== 1 && item.bizRequestFlag) {
|
||||
return null;
|
||||
}
|
||||
// 🔧 Bug #442: 已保存的行必须有有效的 requestId,否则跳过(避免后端删除不存在的记录)
|
||||
if (item.requestId == null || item.requestId === undefined || item.requestId === '') {
|
||||
return null;
|
||||
}
|
||||
return {
|
||||
requestId: item.requestId,
|
||||
dbOpType: '3',
|
||||
adviceType: item.adviceType,
|
||||
};
|
||||
}).filter(item => item !== null); // 过滤掉已签发、已收费、非本人创建或无 requestId 的项目
|
||||
|
||||
if (deleteList.length == 0) {
|
||||
proxy.$modal.msgWarning('只能删除待签发且未收费的项目');
|
||||
return;
|
||||
const canDeleteRow = (item) =>
|
||||
isPendingUnsignedAndUnpaid(item) && isBizRequestAllowedForDelete(item)
|
||||
|
||||
const anySelectedDeletable = groupIndexList.value.some((index) =>
|
||||
canDeleteRow(prescriptionList.value[index])
|
||||
)
|
||||
if (!anySelectedDeletable) {
|
||||
proxy.$modal.msgWarning(
|
||||
'只能删除「待签发」且「未收费」的项目;门诊划价还需为本人开立。已签发、已收费或非本人开立项不可删。'
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
let deleteList = groupIndexList.value
|
||||
.map((index) => {
|
||||
const item = prescriptionList.value[index]
|
||||
if (!canDeleteRow(item)) {
|
||||
return null
|
||||
}
|
||||
if (item.requestId == null || item.requestId === undefined || item.requestId === '') {
|
||||
return null
|
||||
}
|
||||
return {
|
||||
requestId: item.requestId,
|
||||
dbOpType: '3',
|
||||
adviceType: item.adviceType,
|
||||
}
|
||||
})
|
||||
.filter((item) => item !== null)
|
||||
|
||||
// 删除逻辑:按索引从大到小排序,避免删除后索引变化
|
||||
const sortedIndexes = groupIndexList.value.sort((a, b) => b - a);
|
||||
let hasSavedItem = false;
|
||||
|
||||
const sortedIndexes = [...groupIndexList.value].sort((a, b) => b - a)
|
||||
let hasSavedItem = false
|
||||
|
||||
for (const index of sortedIndexes) {
|
||||
const item = prescriptionList.value[index];
|
||||
if (item.statusEnum != 1) {
|
||||
continue; // 跳过已签发的项目
|
||||
const item = prescriptionList.value[index]
|
||||
if (!canDeleteRow(item)) {
|
||||
continue
|
||||
}
|
||||
|
||||
|
||||
if (!item.requestId) {
|
||||
// 新增的行(未保存到数据库),直接删除
|
||||
prescriptionList.value.splice(index, 1);
|
||||
prescriptionList.value.splice(index, 1)
|
||||
} else {
|
||||
hasSavedItem = true;
|
||||
hasSavedItem = true
|
||||
}
|
||||
}
|
||||
|
||||
if (hasSavedItem) {
|
||||
// 🔧 Bug #454: 删除前弹出确认提示,告知用户将级联删除关联检验申请单
|
||||
const hasLabItem = deleteList.some(item => item.adviceType === 3);
|
||||
const confirmMsg = hasLabItem
|
||||
? '删除此医嘱将同时删除关联的检验申请单,是否确认删除?'
|
||||
: '确认删除选中的医嘱项目吗?';
|
||||
|
||||
proxy.$modal.confirm(confirmMsg).then(() => {
|
||||
savePrescription({ adviceSaveList: deleteList }).then((res) => {
|
||||
if (res.code == 200) {
|
||||
proxy.$modal.msgSuccess('操作成功');
|
||||
getListInfo(false);
|
||||
expandOrder.value = [];
|
||||
groupIndexList.value = [];
|
||||
groupList.value = [];
|
||||
isAdding.value = false;
|
||||
adviceQueryParams.value.adviceType = undefined;
|
||||
}
|
||||
});
|
||||
}).catch(() => {
|
||||
// 用户取消删除
|
||||
});
|
||||
} else {
|
||||
// 只有新增行,已经在前端删除完成
|
||||
proxy.$modal.msgSuccess('操作成功');
|
||||
const cleanupAfterDelete = () => {
|
||||
expandOrder.value = [];
|
||||
groupIndexList.value = [];
|
||||
groupList.value = [];
|
||||
isAdding.value = false;
|
||||
adviceQueryParams.value.adviceType = undefined;
|
||||
};
|
||||
|
||||
if (hasSavedItem) {
|
||||
if (deleteList.length === 0) {
|
||||
proxy.$modal.msgWarning('没有可提交删除的已保存医嘱,请刷新后重试');
|
||||
getListInfo(false);
|
||||
cleanupAfterDelete();
|
||||
return;
|
||||
}
|
||||
|
||||
// Bug #454: 删除前确认;检验医嘱提示级联删除申请单
|
||||
const hasLabItem = deleteList.some((item) => item.adviceType === 3);
|
||||
const confirmMsg = hasLabItem
|
||||
? '删除此医嘱将同时删除关联的检验申请单,是否确认删除?'
|
||||
: '确认删除选中的医嘱项目吗?';
|
||||
|
||||
proxy.$modal
|
||||
.confirm(confirmMsg)
|
||||
.then(() => {
|
||||
savePrescription({ adviceSaveList: deleteList }).then((res) => {
|
||||
if (res.code == 200) {
|
||||
proxy.$modal.msgSuccess('操作成功');
|
||||
getListInfo(false);
|
||||
cleanupAfterDelete();
|
||||
}
|
||||
});
|
||||
})
|
||||
.catch(() => {
|
||||
// 用户取消删除
|
||||
});
|
||||
} else {
|
||||
proxy.$modal.msgSuccess('操作成功');
|
||||
cleanupAfterDelete();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user