From 122a15a73d0452e2c7a98157fae9ca0ed074d6fc Mon Sep 17 00:00:00 2001 From: wzk <2438381872@qq.com> Date: Mon, 24 Nov 2025 11:40:37 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=8C=BB=E5=98=B1=E4=BF=9D?= =?UTF-8?q?=E5=AD=98=E3=80=81=E7=AD=BE=E5=8F=91=E4=B8=8D=E6=88=90=E5=8A=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../prescription/prescriptionlist.vue | 85 +++++++++++++++++-- 1 file changed, 78 insertions(+), 7 deletions(-) diff --git a/openhis-ui-vue3/src/views/doctorstation/components/prescription/prescriptionlist.vue b/openhis-ui-vue3/src/views/doctorstation/components/prescription/prescriptionlist.vue index 45e52428..91089646 100644 --- a/openhis-ui-vue3/src/views/doctorstation/components/prescription/prescriptionlist.vue +++ b/openhis-ui-vue3/src/views/doctorstation/components/prescription/prescriptionlist.vue @@ -839,7 +839,10 @@ 待保存 - 待签发 + + 待保存 + + 待签发 {{ scope.row.chargeStatus_enumText }} @@ -1197,6 +1200,13 @@ function refresh() { function getListInfo(addNewRow) { isAdding.value = false; getPrescriptionList(props.patientInfo.encounterId).then((res) => { + // 调试日志:显示后端返回的原始数据 + console.log('[getListInfo] 后端返回的原始数据:', res.data.map(item => ({ + adviceName: JSON.parse(item.contentJson)?.adviceName, + requestId: item.requestId, + statusEnum: item.statusEnum, + contentJson_isSaved: JSON.parse(item.contentJson)?.isSaved + }))); prescriptionList.value = res.data.map((item) => { const parsedContent = JSON.parse(item.contentJson); // 确保 skinTestFlag 是数字类型(1 或 0) @@ -1217,10 +1227,17 @@ function getListInfo(addNewRow) { // 对于中成药类型,特别确保adviceName正确设置 const adviceName = parsedContent?.adviceName || item?.adviceName || ''; + // 根据后端返回的状态设置 isSaved 标识 + // statusEnum == 1 且有 requestId 且后端有 isSaved 字段,则使用后端的值 + // 否则默认为 false(待保存) + const isSaved = item.statusEnum === 1 && item.requestId + ? (parsedContent?.isSaved !== undefined ? parsedContent.isSaved : false) + : (item.statusEnum === 2 ? true : false); + return { ...item, ...parsedContent, - // 确保adviceType是数字类型,以便正确显示文本 + // 确保 adviceType 是数字类型,以便正确显示文本 adviceType: displayAdviceType, doseQuantity: parsedContent?.doseQuantity, doseUnitCode_dictText: parsedContent?.doseUnitCode_dictText, @@ -1230,9 +1247,22 @@ function getListInfo(addNewRow) { rateCode_dictText: parsedContent?.rateCode_dictText || item.rateCode_dictText, methodCode_dictText: parsedContent?.methodCode_dictText || item.methodCode_dictText, dispensePerDuration: parsedContent?.dispensePerDuration || item.dispensePerDuration, - adviceName: adviceName, // 确保adviceName正确设置 + adviceName: adviceName, // 确保 adviceName 正确设置 + isSaved: isSaved, // 设置 isSaved 标识 + statusEnum: item.statusEnum, // 关键修复:确保使用后端返回的 statusEnum,不被 parsedContent 覆盖 + requestId: item.requestId, // 确保 requestId 不被覆盖 }; }); + + // 调试日志:显示所有医嘱的状态 + console.log('[getListInfo] 刷新后的医嘱列表:', prescriptionList.value.map(item => ({ + adviceName: item.adviceName, + requestId: item.requestId, + statusEnum: item.statusEnum, + isSaved: item.isSaved, + 显示状态: item.statusEnum === 2 ? '已签发' : (item.statusEnum === 1 && item.isSaved ? '待签发' : '待保存') + }))); + groupMarkers.value = getGroupMarkers(prescriptionList.value); // 更新标记 if (props.activeTab == 'prescription' && addNewRow) { handleAddPrescription(); @@ -1287,6 +1317,7 @@ function handleAddPrescription() { check: false, isEdit: true, statusEnum: 1, + isSaved: false, // 新增医嘱默认为未保存状态 }); groupMarkers.value = getGroupMarkers(prescriptionList.value); nextTick(() => { @@ -1729,6 +1760,12 @@ function handleOrgChange(value, index) { * 签发处方 */ function handleSave() { + // 验证费用性质是否已选择 + if (!accountId.value) { + proxy.$modal.msgWarning('请先选择费用性质'); + return; + } + if (expandOrder.value.length > 0) { proxy.$modal.msgWarning('请先保存当前医嘱'); return; @@ -1743,12 +1780,15 @@ function handleSave() { }); let validList = saveList.filter((item) => { - return !item.requestId; + return !item.isSaved; }); if (validList.length > 0) { proxy.$modal.msgWarning('存在未保存的医嘱,请先点击保存按钮后再执行签发'); return; } + + // 只签发已保存的医嘱 + saveList = saveList.filter((item) => item.isSaved); if (saveList.length == 0) { proxy.$modal.msgWarning('当前无可签发处方'); return; @@ -1868,6 +1908,12 @@ function stockFormat(partPercent, unit, minUnit, quantity) { // 单行处方保存 function handleSaveSign(row, index) { + // 验证费用性质是否已选择 + if (!accountId.value) { + proxy.$modal.msgWarning('请先选择费用性质'); + return; + } + proxy.$refs['formRef' + index].validate((valid) => { if (valid) { row.isEdit = false; @@ -1918,7 +1964,8 @@ function handleSaveSign(row, index) { const rowToSave = { ...row, adviceType: saveAdviceType, - contentJson: undefined // 确保contentJson不被序列化 + isSaved: false, // 确定后为待保存状态 + contentJson: undefined // 确保 contentJson不被序列化 }; // 对中成药类型(2)特别处理,确保adviceName被正确保存 if (row.adviceType == 2) { @@ -1928,9 +1975,10 @@ function handleSaveSign(row, index) { // 恢复原始的adviceType供前端显示使用 row.adviceType = row.adviceType; - // 确认操作应该只保存为待保存状态(DRAFT),不立即签发 + // 确认操作应该只保存为待保存状态,不设置 isSaved 标识 // 这样用户点击保存按钮时才会变为待签发状态 row.dbOpType = row.requestId ? '2' : '1'; + row.isSaved = false; // 确定后为待保存状态 savePrescription({ adviceSaveList: [row] }).then((res) => { if (res.code === 200) { proxy.$modal.msgSuccess('保存成功'); @@ -1943,6 +1991,12 @@ function handleSaveSign(row, index) { } function handleSaveBatch() { + // 验证费用性质是否已选择 + if (!accountId.value) { + proxy.$modal.msgWarning('请先选择费用性质'); + return; + } + if (expandOrder.value.length > 0) { proxy.$modal.msgWarning('请先点击确定确认当前医嘱'); return; @@ -1954,12 +2008,28 @@ function handleSaveBatch() { } let saveList = prescriptionList.value .filter((item) => { - return item.statusEnum == 1 && !item.requestId; + return item.statusEnum == 1 && !item.isSaved; }) .map((item) => { + // 将前端的耗材类型(4)转换为后端需要的类型(2) + const saveAdviceType = item.adviceType == 4 ? 2 : item.adviceType; + + // 创建要序列化的对象 + const itemToSave = { + ...item, + adviceType: saveAdviceType, + isSaved: true, // 保存后设置为待签发状态 + contentJson: undefined // 避免循环引用 + }; + + // 序列化到 contentJson + const contentJson = JSON.stringify(itemToSave); + return { ...item, dbOpType: item.requestId ? '2' : '1', + isSaved: true, + contentJson: contentJson // 使用新的 contentJson }; }); if (saveList.length == 0) { @@ -2115,6 +2185,7 @@ function handleSaveGroup(orderGroupList) { unitCode: item.unitCode, unitCode_dictText: item.unitCodeName ? item.unitCodeName : '', statusEnum: 1, + isSaved: false, // 组套保存默认为未保存状态 dbOpType: prescriptionList.value[rowIndex.value].requestId ? '2' : '1', minUnitQuantity: unitCodeList.value.find((k) => k.value == item.unitCode).type == 'minUnit'