Selaa lähdekoodia

feat:修改报告对接逻辑

wangsisi 4 päivää sitten
vanhempi
commit
fa269fae95
1 muutettua tiedostoa jossa 25 lisäystä ja 15 poistoa
  1. 25 15
      src/views/old_mini/agri_file/index.vue

+ 25 - 15
src/views/old_mini/agri_file/index.vue

@@ -438,7 +438,17 @@ async function fetchReportList() {
 
     const riskData = unwrapApiData(riskRaw);
     const stressData = unwrapApiData(stressRaw);
-    const abnormalReports = abnormalRaw?.code === 200 && abnormalRaw?.data?.report
+    // query_abnormal_report:data.reports / data.report 均为报告数组
+    const abnormalRes = Array.isArray(abnormalRaw) ? abnormalRaw[0] : abnormalRaw;
+    const abnormalRawList =
+        Number(abnormalRes?.code) === 200
+            ? abnormalRes?.data?.reports ?? abnormalRes?.data?.report
+            : null;
+    const abnormalReports = Array.isArray(abnormalRawList)
+        ? abnormalRawList
+        : abnormalRawList && typeof abnormalRawList === "object"
+          ? [abnormalRawList]
+          : [];
 
     const baseList = [
         {
@@ -462,21 +472,21 @@ async function fetchReportList() {
             cover,
         },
     ].filter((item) => item.title || item.desc);
-    
-    if(abnormalReports?.id){
-        const abnormalList = [{
-            id: `abnormal-${abnormalReports.id}`,
-            reportId: abnormalReports.id,
-            type: "abnormal_report",
-            title: "异常农情诊断报告",
-            desc: abnormalReports.explain_simple || "",
-            cover :abnormalReports.cover_url || cover,
-        }]
-        reportList.value = [...baseList, ...abnormalList];
-    }else{
-        reportList.value = baseList;
-    }
 
+    const abnormalList = abnormalReports
+        .filter((item) => item && (item.id != null || item.analysis || item.explain_simple))
+        .map((item) => ({
+            id: `abnormal-${item.id}`,
+            reportId: item.id,
+            type: "abnormal_report",
+            title: item.title || "异常农情诊断报告",
+            // 卡片简介:analysis[].desc
+            desc:item.explain_simple ||"",
+            cover: item.cover_url || cover,
+            date: pickReportDate(item),
+        }));
+
+    reportList.value = [...baseList, ...abnormalList];
 }
 
 const showUploadPopup = ref(false);