Przeglądaj źródła

feat: suggestDiag 赋值改为候选规范化+默认第一个

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
张田田 1 tydzień temu
rodzic
commit
72ed3146b2
1 zmienionych plików z 16 dodań i 6 usunięć
  1. 16 6
      src/views/diagnosis/Prescribing.vue

+ 16 - 6
src/views/diagnosis/Prescribing.vue

@@ -2553,12 +2553,22 @@ export default {
 
         // 西医主诊断(只读,接口返回)和建议诊断(用户输入)
         this.westernDiag = techData.westernDiag || '';
-        // 建议诊断(多选,从接口返回)
-        if (techData.suggestDiag) {
-          this.suggestDiag = typeof techData.suggestDiag === 'string'
-            ? techData.suggestDiag.split(',').filter(Boolean)
-            : Array.isArray(techData.suggestDiag) ? techData.suggestDiag : [];
-        }
+        // 建议诊断候选(后端返回的全部)→ 规范化成对象数组,并预填充 name 映射
+        const rawSuggest = techData.suggestDiag;
+        const rawArr = typeof rawSuggest === 'string'
+          ? rawSuggest.split(',').filter(Boolean)
+          : Array.isArray(rawSuggest) ? rawSuggest : [];
+        this.suggestDiagAll = rawArr.map(it => {
+          if (it && typeof it === 'object') {
+            const code = it.westcode || it.code;
+            return { westcode: code, westname: it.westname || it.name || code };
+          }
+          return { westcode: it, westname: this.westernDiseaseNameMap[it] || it };
+        });
+        this.suggestDiagAll.forEach(it => {
+          if (it.westcode) this.westernDiseaseNameMap[it.westcode] = it.westname;
+        });
+        this.suggestDiag = this.suggestDiagAll.length ? [this.suggestDiagAll[0].westcode] : [];
 
         // 合并所有数据中的treatmentList
         const mergedTreatmentList = dataArray.reduce((acc, item) => {