修复了作废的中医诊断也显示出来的问题,
This commit is contained in:
@@ -91,6 +91,8 @@ import {
|
||||
getTcmCondition,
|
||||
getTcmSyndrome,
|
||||
saveTcmDiagnosis,
|
||||
deleteTcmDiagnosis,
|
||||
getTcmDiagnosis,
|
||||
} from '@/views/doctorstation/components/api';
|
||||
|
||||
const props = defineProps({
|
||||
@@ -115,9 +117,38 @@ const { proxy } = getCurrentInstance();
|
||||
const emit = defineEmits(['close']);
|
||||
|
||||
function handleOpen() {
|
||||
// 加载诊断和证候选项
|
||||
getTcmCondition().then((res) => {
|
||||
conditionList.value = res.data.records;
|
||||
});
|
||||
|
||||
// 加载已保存的中医诊断
|
||||
getTcmDiagnosis({ encounterId: props.patientInfo.encounterId }).then((res) => {
|
||||
if (res.data && res.data.illness && res.data.illness.length > 0) {
|
||||
tcmDiagonsisList.value = [];
|
||||
tcmDiagonsisSaveList.value = [];
|
||||
|
||||
res.data.illness.forEach((illness, index) => {
|
||||
const symptom = res.data.symptom[index];
|
||||
const syndromeGroupNo = illness.syndromeGroupNo || symptom.syndromeGroupNo;
|
||||
|
||||
tcmDiagonsisList.value.push({
|
||||
conditionName: illness.name,
|
||||
syndromeName: symptom.name,
|
||||
syndromeGroupNo: syndromeGroupNo,
|
||||
isSaved: true, // 标记为已保存的诊断
|
||||
});
|
||||
|
||||
tcmDiagonsisSaveList.value.push({
|
||||
definitionId: illness.definitionId,
|
||||
syndromeGroupNo: syndromeGroupNo,
|
||||
isSaved: true,
|
||||
});
|
||||
});
|
||||
}
|
||||
}).catch((error) => {
|
||||
console.error('加载中医诊断失败:', error);
|
||||
});
|
||||
}
|
||||
|
||||
// 点击诊断列表处理,点击以后才显示证候列表
|
||||
@@ -155,10 +186,34 @@ function clickSyndromeRow(row) {
|
||||
|
||||
// 删除诊断
|
||||
function removeDiagnosis(row, index) {
|
||||
// 如果是已保存的诊断,需要调用API从服务器删除
|
||||
if (row.isSaved && row.syndromeGroupNo) {
|
||||
proxy.$modal.confirm('确定要删除这个中医诊断吗?').then(() => {
|
||||
deleteTcmDiagnosis(row.syndromeGroupNo).then((res) => {
|
||||
if (res.code === 200) {
|
||||
proxy.$modal.msgSuccess('删除成功');
|
||||
// 从列表中移除
|
||||
tcmDiagonsisList.value.splice(index, 1);
|
||||
tcmDiagonsisSaveList.value = tcmDiagonsisSaveList.filter((item) => {
|
||||
tcmDiagonsisSaveList.value = tcmDiagonsisSaveList.value.filter((item) => {
|
||||
return item.syndromeGroupNo !== row.syndromeGroupNo;
|
||||
});
|
||||
} else {
|
||||
proxy.$modal.msgError(res.msg || '删除失败');
|
||||
}
|
||||
}).catch((error) => {
|
||||
console.error('删除中医诊断失败:', error);
|
||||
proxy.$modal.msgError('删除失败,请重试');
|
||||
});
|
||||
}).catch(() => {
|
||||
// 用户取消删除
|
||||
});
|
||||
} else {
|
||||
// 未保存的诊断,直接从数组中删除
|
||||
tcmDiagonsisList.value.splice(index, 1);
|
||||
tcmDiagonsisSaveList.value = tcmDiagonsisSaveList.value.filter((item) => {
|
||||
return item.syndromeGroupNo !== row.syndromeGroupNo;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function save() {
|
||||
|
||||
@@ -401,7 +401,7 @@
|
||||
</el-table>
|
||||
</div>
|
||||
</div>
|
||||
<tcmdiagnosisDialog ref="tcmDianosis" :patientInfo="props.patientInfo" @flush="getListInfo()" />
|
||||
<tcmdiagnosisDialog ref="tcmDianosis" :patientInfo="props.patientInfo" @flush="handleDiagnosisFlush()" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -414,6 +414,7 @@ import {
|
||||
getOrgTree,
|
||||
signTcmAdvice,
|
||||
getTcmDiagnosis,
|
||||
deleteTcmDiagnosis,
|
||||
signOutTcmAdvice,
|
||||
updateGroupId,
|
||||
getContract,
|
||||
@@ -645,13 +646,15 @@ function getListInfo(addNewRow) {
|
||||
function getDiagnosisInfo() {
|
||||
diagnosisList.value = [];
|
||||
getTcmDiagnosis({ encounterId: props.patientInfo.encounterId }).then((res) => {
|
||||
if (res.data.illness.length > 0) {
|
||||
if (res.data.illness && res.data.illness.length > 0) {
|
||||
res.data.illness.forEach((item, index) => {
|
||||
diagnosisList.value.push({
|
||||
name: item.name + '-' + res.data.symptom[index].name,
|
||||
definitionId: item.definitionId,
|
||||
encounterDiagnosisId: item.encounterDiagnosisId,
|
||||
conditionId: item.conditionId,
|
||||
syndromeGroupNo: item.syndromeGroupNo || res.data.symptom[index].syndromeGroupNo, // 保存syndromeGroupNo用于删除
|
||||
...item, // 保存完整的item数据
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -752,19 +755,31 @@ function openDialog() {
|
||||
tcmDianosis.value.openDialog();
|
||||
}
|
||||
|
||||
function deleteDiagnosisBind(id) {
|
||||
const data = localStorage.getItem(`tcmDiagnosisList_${props.patientInfo.encounterId}`);
|
||||
let list = [];
|
||||
list = JSON.parse(data);
|
||||
// 添加到列表
|
||||
const index = list.findIndex((item) => item.id === id);
|
||||
if (index === -1) return;
|
||||
function deleteDiagnosisBind(syndromeGroupNo) {
|
||||
if (!syndromeGroupNo) {
|
||||
proxy.$modal.msgWarning('缺少诊断标识,无法删除');
|
||||
return;
|
||||
}
|
||||
|
||||
list.splice(index, 1);
|
||||
localStorage.removeItem(`tcmDiagnosisList_${props.patientInfo.encounterId}`);
|
||||
// 保存到本地缓存
|
||||
localStorage.setItem(`tcmDiagnosisList_${props.patientInfo.encounterId}`, JSON.stringify(list));
|
||||
// 调用API从服务器删除中医诊断
|
||||
deleteTcmDiagnosis(syndromeGroupNo).then((res) => {
|
||||
if (res.code === 200) {
|
||||
proxy.$modal.msgSuccess('删除成功');
|
||||
handleDiagnosisFlush();
|
||||
} else {
|
||||
proxy.$modal.msgError(res.msg || '删除失败');
|
||||
}
|
||||
}).catch((error) => {
|
||||
console.error('删除中医诊断失败:', error);
|
||||
proxy.$modal.msgError('删除失败,请重试');
|
||||
});
|
||||
}
|
||||
|
||||
// 诊断数据刷新处理函数
|
||||
function handleDiagnosisFlush() {
|
||||
// 同时刷新医嘱列表和诊断列表,确保诊断数据同步
|
||||
getListInfo();
|
||||
getDiagnosisInfo();
|
||||
}
|
||||
|
||||
function addNewPrescription(){
|
||||
|
||||
@@ -82,28 +82,29 @@ function submit() {
|
||||
return; // 确保选择了诊断和证候
|
||||
}
|
||||
|
||||
// 构建诊断对象
|
||||
const diagnosis = {
|
||||
id: Date.now(), // 使用时间戳作为唯一ID
|
||||
condition: conditionOptions.value.find((item) => item.value === condition.value)?.label || '',
|
||||
// 构建诊断数据,调用API保存到服务器
|
||||
const diagnosisChildList = [{
|
||||
conditionCode: condition.value,
|
||||
syndrome: syndromeOptions.value.find((item) => item.value === syndrome.value)?.label || '',
|
||||
syndromeCode: syndrome.value,
|
||||
};
|
||||
const data = localStorage.getItem(`tcmDiagnosisList_${props.patientInfo.encounterId}`);
|
||||
diagnosisList.value = JSON.parse(data);
|
||||
// 添加到列表
|
||||
diagnosisList.value.push(diagnosis);
|
||||
localStorage.removeItem(`tcmDiagnosisList_${props.patientInfo.encounterId}`);
|
||||
// 保存到本地缓存
|
||||
localStorage.setItem(
|
||||
`tcmDiagnosisList_${props.patientInfo.encounterId}`,
|
||||
JSON.stringify(diagnosisList.value)
|
||||
);
|
||||
}];
|
||||
|
||||
console.log('当前诊断列表:', diagnosisList.value);
|
||||
emit('flush')
|
||||
// 调用API保存到服务器
|
||||
saveTcmDiagnosis({
|
||||
patientId: props.patientInfo.patientId,
|
||||
encounterId: props.patientInfo.encounterId,
|
||||
diagnosisChildList: diagnosisChildList,
|
||||
}).then((res) => {
|
||||
if (res.code === 200) {
|
||||
proxy.$modal.msgSuccess('保存成功');
|
||||
emit('flush');
|
||||
close();
|
||||
} else {
|
||||
proxy.$modal.msgError(res.msg || '保存失败');
|
||||
}
|
||||
}).catch((error) => {
|
||||
console.error('保存中医诊断失败:', error);
|
||||
proxy.$modal.msgError('保存失败,请重试');
|
||||
});
|
||||
}
|
||||
|
||||
function openDialog() {
|
||||
|
||||
Reference in New Issue
Block a user