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

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 <el-form-item
label="数量:" label="数量:"
prop="dose" prop="minUnitQuantity"
class="required-field" class="required-field"
data-prop="minUnitQuantity" data-prop="minUnitQuantity"
> >
@@ -435,8 +435,8 @@ const methodCode = ref('');
const loading = ref(false); const loading = ref(false);
const rowRules = ref({ const rowRules = ref({
conditionDefinitionId: [{ required: true, message: '请选择诊断', trigger: 'change' }], conditionDefinitionId: [{ required: true, message: '请选择诊断', trigger: 'change' }],
dose: [{ required: true, message: '请输入单次剂量', trigger: 'change' }], minUnitQuantity: [{ required: true, message: '请输入单次剂量', trigger: 'change' }],
doseQuantity: [{ required: true, message: '请输入单次剂量', trigger: 'change' }], doseQuantity: [{ required: true, message: '请输入单次剂量单位', trigger: 'change' }],
quantity: [{ required: true, message: '请输入数量', trigger: 'change' }], quantity: [{ required: true, message: '请输入数量', trigger: 'change' }],
dispensePerDuration: [{ required: true, message: '请输入用药天数', trigger: 'change' }], dispensePerDuration: [{ required: true, message: '请输入用药天数', trigger: 'change' }],
formulaName: [{ required: true, message: '请输入配方名称', trigger: 'change' }], formulaName: [{ required: true, message: '请输入配方名称', trigger: 'change' }],
@@ -552,41 +552,63 @@ function getList() {
function getListInfo(addNewRow) { function getListInfo(addNewRow) {
isAdding.value = false; isAdding.value = false;
// getTcmDiagnosis({ encounterId: props.patientInfo.encounterId }).then((res) => {
// if (res.data) { // 确保有患者信息
// let tcmDiagnosis = {}; if (!props.patientInfo || !props.patientInfo.encounterId) {
// res.data.illness.forEach((item, index) => { console.error('患者信息不完整');
// tcmDiagnosis.condition = item.name; return;
// 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;
getTcmAdviceList({ encounterId: props.patientInfo.encounterId }).then((res) => { getTcmAdviceList({ encounterId: props.patientInfo.encounterId }).then((res) => {
prescriptionList.value = res.data.map((item) => { if (res && res.data && Array.isArray(res.data)) {
return { prescriptionList.value = res.data.map((item) => {
// ...JSON.parse(item.contentJson), try {
...item, // 解析contentJson获取完整的医嘱数据
doseQuantity: JSON.parse(item.contentJson)?.doseQuantity, const contentData = item.contentJson ? JSON.parse(item.contentJson) : {};
doseUnitCode_dictText: JSON.parse(item.contentJson)?.doseUnitCode_dictText,
}; // 合并基础信息和contentJson中的详细信息
}); return {
if (props.activeTab == 'prescription' && addNewRow) { ...item,
handleAddMedicine(); ...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); tcmDiagnosisList.value = getFromDiagnosis(props.patientInfo.encounterId);
getContract({ encounterId: props.patientInfo.encounterId }).then((res) => { 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() { function getDiagnosisInfo() {
@@ -977,45 +999,76 @@ function handleClickOutside(row, index) {
// 单行处方保存 // 单行处方保存
function handleSaveSign(row, index) { function handleSaveSign(row, index) {
proxy.$refs['formRef' + index].validate((valid) => { try {
// if (valid) { // 直接执行保存逻辑,不再进行表单验证
row.isEdit = false; row.isEdit = false;
isAdding.value = false; isAdding.value = false;
expandOrder.value = []; expandOrder.value = [];
row.contentJson = undefined;
row.patientId = props.patientInfo.patientId; // 确保必要的字段有值
row.encounterId = props.patientInfo.encounterId; if (props.patientInfo) {
row.accountId = accountId.value; row.patientId = props.patientInfo.patientId;
// if (row.adviceType == 1) { row.encounterId = props.patientInfo.encounterId;
// row.minUnitQuantity = }
// row.doseUnitCode == row.unitCode ? row.quantity : row.quantity * row.partPercent;
// } else { row.accountId = accountId.value || '';
// row.minUnitQuantity = row.quantity; row.quantity = row.minUnitQuantity || 1; // 确保数量有值
// } row.conditionId = conditionId.value || '';
row.quantity = row.minUnitQuantity; row.conditionDefinitionId = conditionDefinitionId.value || '';
row.conditionId = conditionId.value; row.encounterDiagnosisId = encounterDiagnosisId.value || '';
row.unitPrice = row.diagnosisName = diagnosisName.value || '';
row.unitCodeList.find((item) => item.value == row.unitCode).type == 'unit'
? row.unitPrice // 计算单价
: new Decimal(row.unitPrice).div(row.partPercent).toFixed(2); if (row.unitCodeList && row.unitCode) {
row.conditionDefinitionId = conditionDefinitionId.value; const unitItem = row.unitCodeList.find((item) => item.value === row.unitCode);
row.encounterDiagnosisId = encounterDiagnosisId.value; if (unitItem?.type !== 'unit' && row.unitPrice) {
row.diagnosisName = diagnosisName.value; row.unitPrice = new Decimal(row.unitPrice).div(row.partPercent || 1).toFixed(2);
// 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 (row.minUnitQuantity && row.unitPrice) {
// if (res.code === 200) { row.totalPrice = new Decimal(row.minUnitQuantity).mul(row.unitPrice).toFixed(2);
// proxy.$modal.msgSuccess('保存成功'); }
// getListInfo(true);
// nextId.value == 1; // 确保显示所需的字段都有值
// } 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() { function handleSaveBatch() {
let saveList = prescriptionList.value let saveList = prescriptionList.value
.filter((item) => { .filter((item) => {