fix(order): 解决医嘱类型字段处理问题

- 优化了JSON解析逻辑,避免重复解析contentJson字段
- 确保therapyEnum字段正确传递,默认值设置为长期医嘱('1')
- 修复了医嘱保存和签发过程中类型字段丢失的问题
- 统一了前后端therapyEnum字段的默认值处理逻辑
- 添加了必要的注释说明字段处理规则
This commit is contained in:
2026-03-12 12:42:17 +08:00
parent cf3f971741
commit 4277a369d2
3 changed files with 29 additions and 9 deletions

View File

@@ -541,11 +541,14 @@ function getListInfo(addNewRow) {
loadingInstance.close();
prescriptionList.value = res.data
.map((item) => {
const parsedContent = JSON.parse(item.contentJson);
return {
...JSON.parse(item.contentJson),
...parsedContent,
...item,
doseQuantity: JSON.parse(item.contentJson)?.doseQuantity,
doseUnitCode_dictText: JSON.parse(item.contentJson)?.doseUnitCode_dictText,
doseQuantity: parsedContent?.doseQuantity,
doseUnitCode_dictText: parsedContent?.doseUnitCode_dictText,
// 确保 therapyEnum 被正确设置,优先使用 contentJson 中的值
therapyEnum: String(parsedContent?.therapyEnum ?? item.therapyEnum ?? '1'),
};
})
.sort((a, b) => {
@@ -604,7 +607,7 @@ function handleAddPrescription() {
showPopover: false,
isEdit: true,
statusEnum: 1,
therapyEnum: '1',
therapyEnum: '1', // 默认为长期医嘱
});
getGroupMarkers();
nextTick(() => {
@@ -641,8 +644,8 @@ function clickRowDb(row, column, event) {
}
row.showPopover = false;
if (row.statusEnum == 1) {
// 确保治疗类型为字符串,方便与单选框 label 对齐
row.therapyEnum = String(row.therapyEnum ?? '');
// 确保治疗类型为字符串,方便与单选框 label 对齐,默认为长期医嘱('1')
row.therapyEnum = String(row.therapyEnum ?? '1');
row.isEdit = true;
const index = prescriptionList.value.findIndex((item) => item.uniqueKey === row.uniqueKey);
prescriptionList.value[index] = row;
@@ -879,13 +882,16 @@ function handleSave() {
// 此处签发处方和单行保存处方传参相同后台已经将传参存为JSON字符串此处直接转换为JSON即可
loading.value = true;
let list = saveList.map((item) => {
const parsedContent = JSON.parse(item.contentJson);
return {
...JSON.parse(item.contentJson),
...parsedContent,
adviceType: item.adviceType,
requestId: item.requestId,
dbOpType: '1',
groupId: item.groupId,
uniqueKey: undefined,
// 确保 therapyEnum 被正确传递
therapyEnum: parsedContent.therapyEnum || item.therapyEnum || '1',
};
});
// 保存签发按钮
@@ -1059,6 +1065,8 @@ function handleSaveSign(row, index) {
row.conditionDefinitionId = conditionDefinitionId.value;
row.encounterDiagnosisId = encounterDiagnosisId.value;
row.diagnosisName = diagnosisName.value;
// 确保 therapyEnum 被正确设置,默认为长期医嘱('1')
row.therapyEnum = row.therapyEnum || '1';
if (row.injectFlag == 1) {
row.sortNumber = row.sortNumber ? row.sortNumber : prescriptionList.value.length;
}
@@ -1098,8 +1106,11 @@ function handleSaveBatch() {
return item.statusEnum == 1 && !item.requestId;
})
.map((item) => {
// 确保 therapyEnum 被正确传递,默认为长期医嘱('1')
const therapyEnum = item.therapyEnum || '1';
return {
...item,
therapyEnum: therapyEnum,
dbOpType: item.requestId ? '2' : '1',
};
});
@@ -1246,6 +1257,8 @@ function handleSaveGroup(orderGroupList) {
conditionId: conditionId.value, // 诊断id
conditionDefinitionId: conditionDefinitionId.value, // 诊断定义id
encounterDiagnosisId: encounterDiagnosisId.value, // 就诊诊断id
// 确保 therapyEnum 被正确设置,默认为长期医嘱('1')
therapyEnum: prescriptionList.value[rowIndex.value]?.therapyEnum || '1',
};
// 计算价格和总量
@@ -1278,7 +1291,12 @@ function handleSaveHistory(value) {
conditionId: conditionId.value,
conditionDefinitionId: conditionDefinitionId.value,
encounterDiagnosisId: encounterDiagnosisId.value,
contentJson: JSON.stringify(value),
// 确保 therapyEnum 被正确传递,默认为长期医嘱('1')
therapyEnum: value.therapyEnum || '1',
contentJson: JSON.stringify({
...value,
therapyEnum: value.therapyEnum || '1',
}),
};
savePrescription({ adviceSaveList: [saveRow], regAdviceSaveList: [saveRow] }).then((res) => {
if (res.code === 200) {