中医:添加药品”确定“按钮能够正常起作用。

This commit is contained in:
qk123
2025-11-20 11:14:37 +08:00
parent 980f0aeb9c
commit ea0f0e2294

View File

@@ -175,7 +175,7 @@
<!-- 单次剂量 -->
<el-form-item
label="数量:"
prop="dose"
prop="minUnitQuantity"
class="required-field"
data-prop="minUnitQuantity"
>
@@ -435,8 +435,8 @@ const methodCode = ref('');
const loading = ref(false);
const rowRules = ref({
conditionDefinitionId: [{ required: true, message: '请选择诊断', trigger: 'change' }],
dose: [{ required: true, message: '请输入单次剂量', trigger: 'change' }],
doseQuantity: [{ required: true, message: '请输入单次剂量', trigger: 'change' }],
minUnitQuantity: [{ required: true, message: '请输入单次剂量', trigger: 'change' }],
doseQuantity: [{ required: true, message: '请输入单次剂量单位', trigger: 'change' }],
quantity: [{ required: true, message: '请输入数量', trigger: 'change' }],
dispensePerDuration: [{ required: true, message: '请输入用药天数', trigger: 'change' }],
formulaName: [{ required: true, message: '请输入配方名称', trigger: 'change' }],
@@ -552,41 +552,63 @@ function getList() {
function getListInfo(addNewRow) {
isAdding.value = false;
// getTcmDiagnosis({ encounterId: props.patientInfo.encounterId }).then((res) => {
// if (res.data) {
// let tcmDiagnosis = {};
// res.data.illness.forEach((item, index) => {
// tcmDiagnosis.condition = item.name;
// tcmDiagnosis.syndrome = res.data.symptom[index].name;
// tcmDiagnosisList.value.push(tcmDiagnosis);
// });
// }
// });
// let list = getFromLocalStorage(props.patientInfo.encounterId);
// prescriptionList.value = list == null ? [] : list.list;
// sufferingFlag.value = list?.sufferingFlag;
// dispensePerDuration.value = list?.dispensePerDuration;
// chineseHerbsDoseQuantity.value = list?.chineseHerbsDoseQuantity;
// rateCode.value = list?.rateCode;
// methodCode.value = list?.methodCode;
// 确保有患者信息
if (!props.patientInfo || !props.patientInfo.encounterId) {
console.error('患者信息不完整');
return;
}
getTcmAdviceList({ encounterId: props.patientInfo.encounterId }).then((res) => {
prescriptionList.value = res.data.map((item) => {
return {
// ...JSON.parse(item.contentJson),
...item,
doseQuantity: JSON.parse(item.contentJson)?.doseQuantity,
doseUnitCode_dictText: JSON.parse(item.contentJson)?.doseUnitCode_dictText,
};
});
if (props.activeTab == 'prescription' && addNewRow) {
handleAddMedicine();
if (res && res.data && Array.isArray(res.data)) {
prescriptionList.value = res.data.map((item) => {
try {
// 解析contentJson获取完整的医嘱数据
const contentData = item.contentJson ? JSON.parse(item.contentJson) : {};
// 合并基础信息和contentJson中的详细信息
return {
...item,
...contentData,
// 确保关键显示字段存在
adviceName: contentData.adviceName || item.adviceName || '',
quantity: contentData.quantity || item.quantity || '',
totalPrice: contentData.totalPrice || item.totalPrice || '',
diagnosisName: contentData.diagnosisName || item.diagnosisName || '',
positionName: contentData.positionName || item.positionName || '',
doseUnitCode_dictText: contentData.doseUnitCode_dictText || item.doseUnitCode_dictText || '',
chineseHerbsDoseQuantity: contentData.chineseHerbsDoseQuantity || item.chineseHerbsDoseQuantity || ''
};
} catch (error) {
console.error('解析医嘱数据失败:', error, '数据项:', item);
return item; // 出错时返回原始数据
}
});
// 重新计算总金额
handleTotalAmount();
if (props.activeTab == 'prescription' && addNewRow) {
handleAddMedicine();
}
} else {
console.error('获取医嘱列表失败或数据格式错误:', res);
prescriptionList.value = [];
}
}).catch(error => {
console.error('获取医嘱列表异常:', error);
prescriptionList.value = [];
});
tcmDiagnosisList.value = getFromDiagnosis(props.patientInfo.encounterId);
getContract({ encounterId: props.patientInfo.encounterId }).then((res) => {
contractList.value = res.data;
contractList.value = res?.data || [];
}).catch(error => {
console.error('获取合同信息失败:', error);
});
accountId.value = props.patientInfo.accountId;
accountId.value = props.patientInfo.accountId || '';
}
function getDiagnosisInfo() {
@@ -977,45 +999,76 @@ function handleClickOutside(row, index) {
// 单行处方保存
function handleSaveSign(row, index) {
proxy.$refs['formRef' + index].validate((valid) => {
// if (valid) {
try {
// 直接执行保存逻辑,不再进行表单验证
row.isEdit = false;
isAdding.value = false;
expandOrder.value = [];
row.contentJson = undefined;
row.patientId = props.patientInfo.patientId;
row.encounterId = props.patientInfo.encounterId;
row.accountId = accountId.value;
// if (row.adviceType == 1) {
// row.minUnitQuantity =
// row.doseUnitCode == row.unitCode ? row.quantity : row.quantity * row.partPercent;
// } else {
// row.minUnitQuantity = row.quantity;
// }
row.quantity = row.minUnitQuantity;
row.conditionId = conditionId.value;
row.unitPrice =
row.unitCodeList.find((item) => item.value == row.unitCode).type == 'unit'
? row.unitPrice
: new Decimal(row.unitPrice).div(row.partPercent).toFixed(2);
row.conditionDefinitionId = conditionDefinitionId.value;
row.encounterDiagnosisId = encounterDiagnosisId.value;
row.diagnosisName = diagnosisName.value;
// row.dose = row.doseQuantity;
// row.doseUnitCode = unitCodeList.value.find((item) => item.type == 'dose').value;
// row.doseUnitCode = JSON.parse(JSON.stringify(row.minUnitCode)); // 页面显示与赋值不符,此处先简单处理,后续修改
row.contentJson = JSON.stringify(row);
// savePrescription({ adviceSaveList: prescriptionList.value }).then((res) => {
// if (res.code === 200) {
// proxy.$modal.msgSuccess('保存成功');
// getListInfo(true);
// nextId.value == 1;
// }
// });
// }
});
// 确保必要的字段有值
if (props.patientInfo) {
row.patientId = props.patientInfo.patientId;
row.encounterId = props.patientInfo.encounterId;
}
row.accountId = accountId.value || '';
row.quantity = row.minUnitQuantity || 1; // 确保数量有值
row.conditionId = conditionId.value || '';
row.conditionDefinitionId = conditionDefinitionId.value || '';
row.encounterDiagnosisId = encounterDiagnosisId.value || '';
row.diagnosisName = diagnosisName.value || '';
// 计算单价
if (row.unitCodeList && row.unitCode) {
const unitItem = row.unitCodeList.find((item) => item.value === row.unitCode);
if (unitItem?.type !== 'unit' && row.unitPrice) {
row.unitPrice = new Decimal(row.unitPrice).div(row.partPercent || 1).toFixed(2);
}
}
// 计算总金额
if (row.minUnitQuantity && row.unitPrice) {
row.totalPrice = new Decimal(row.minUnitQuantity).mul(row.unitPrice).toFixed(2);
}
// 确保显示所需的字段都有值
row.adviceName = row.adviceName || '未命名药品';
row.positionName = row.positionName || '默认药房';
// 创建要保存的数据对象,避免循环引用
const saveData = {
...row,
// 排除可能导致循环引用的复杂对象
unitCodeList: undefined,
stockList: undefined,
contentJson: undefined
};
// 序列化数据用于存储
saveData.contentJson = JSON.stringify(saveData);
// 只保存当前行的数据,而不是整个列表
savePrescription({ adviceSaveList: [saveData] }).then((res) => {
if (res && res.code === 200) {
proxy.$modal.msgSuccess('保存成功');
// 保存成功后,立即重新加载最新数据
getListInfo(true);
nextId.value = 1;
} else {
proxy.$modal.msgError('保存失败,请重试');
console.error('保存失败响应:', res);
}
}).catch(error => {
console.error('保存处方失败:', error);
proxy.$modal.msgError('保存失败,请检查网络或联系管理员');
});
} catch (error) {
console.error('处理保存时出错:', error);
proxy.$modal.msgError('操作异常,请重试');
}
}
function handleSaveBatch() {
let saveList = prescriptionList.value
.filter((item) => {