Quellcode durchsuchen

feat: 增加诊断报告

lxf vor 3 Tagen
Ursprung
Commit
6a18165805

+ 15 - 0
src/api/modules/pheno.js

@@ -37,4 +37,19 @@ module.exports = {
         url: config.base_new_url + "questionnaire/delete_farm_information",
         type: "post",
     },
+    // 上传异常照片
+    uploadAbnormalPhoto: {
+        url: config.base_new_url + "report/inspect_by_zone",
+        type: "post",
+    },
+    // 查询异常报告生成状态
+    getAbnormalReportStatus: {
+        url: config.base_new_url + "report/inspect_task_status",
+        type: "get",
+    },
+    // 查询异常分析报告
+    getAbnormalAnalysisReport: {
+        url: config.base_new_url + "report/query_abnormal_report_by_zone",
+        type: "get",
+    },
 }

+ 11 - 20
src/components/allGarden.vue

@@ -38,6 +38,13 @@
                             <div class="farm-card__title-row">
                                 <span class="farm-name van-ellipsis">{{ item.name }}</span>
                                 <span v-if="item.categoryLabel" class="category-tag">{{ item.categoryLabel }}</span>
+                                <div
+                                    v-if="canDeleteFarm(item) && !item.isCurrent"
+                                    class="del-icon"
+                                    @click.stop="handleDeleteFarm(item)"
+                                >
+                                    <el-icon color="#B5B5B5" size="14"><Delete /></el-icon>
+                                </div>
                             </div>
                         </div>
                         <div v-if="item.isCurrent" class="action-btn action-btn-current">
@@ -57,15 +64,6 @@
                         {{ item.rawAddress || t("common.noAddress") }}
                     </div>
 
-
-                    <!-- <div
-                        v-if="canDeleteFarm(item) && !item.isCurrent"
-                        class="del-icon"
-                        @click.stop="handleDeleteFarm(item)"
-                    >
-                        <el-button type="danger" link :icon="Delete" circle />
-                    </div> -->
-
                     <div class="phenology-box">
                         {{ t("garden.currentPhenology") }}
                         <span class="phenology-text">{{ item.phenologyText || t("garden.phenologyPlaceholder") }}</span>
@@ -614,6 +612,10 @@ onActivated(() => {
     gap: 8px;
     min-width: 0;
 }
+.del-icon {
+    margin-top: 4px;
+    padding: 0 4px;
+}
 
 .farm-name {
     max-width: 180px;
@@ -648,17 +650,6 @@ onActivated(() => {
     }
 }
 
-.del-icon {
-    display: flex;
-    justify-content: flex-end;
-    margin-top: 4px;
-
-    :deep(.el-button) {
-        padding: 4px;
-        font-size: 16px;
-    }
-}
-
 .action-btn {
     flex-shrink: 0;
     height: 26px;

+ 7 - 0
src/router/globalRoutes.js

@@ -117,6 +117,13 @@ export default [
         meta: { keepAlive: true },
         component: () => import("@/views/old_mini/agri_file/pages/abnormalTrack.vue"),
     },
+    // 异常诊断报告详情
+    {
+        path: "/abnormal_diagnosis_report",
+        name: "AbnormalDiagnosisReport",
+        meta: { keepAlive: false },
+        component: () => import("@/views/old_mini/agri_file/pages/abnormal_diagnosis_report.vue"),
+    },
     // 土壤根系互动巡园要点
     {
         path: "/soil_root_track",

+ 40 - 3
src/views/old_mini/agri_file/components/patrolPanel.vue

@@ -100,6 +100,7 @@ import { ElMessage } from "element-plus";
 import { Camera, Clock, Plus, WarningFilled } from "@element-plus/icons-vue";
 import { useI18n } from "@/i18n";
 import { base_img_url2 } from "@/api/config";
+import { resolvePairedFarmZone } from "@/utils/selectedFarm";
 import PhenologyTrackTimelineItem from "@/components/pageComponents/PhenologyTrackTimelineItem.vue";
 import albumUploadPopup from "./albumUploadPopup.vue";
 import tipPopup from "@/components/popup/tipPopup.vue";
@@ -160,6 +161,8 @@ const cropArchiveList = ref([]);
 const showUploadPopup = ref(false);
 const showSuccessPopup = ref(false);
 const uploadZoneId = ref("");
+/** 当前上传来源卡片类型:growth 走相册接口;abnormal / soil 走巡检接口 */
+const uploadCardType = ref("");
 /** 范围校验进行中,避免重复点击触发多次跳转 */
 const uploadChecking = ref(false);
 /** 新增品种前校验范围,避免重复跳转 */
@@ -403,11 +406,10 @@ const fetchCropArchive = async () => {
     }
 };
 
-/** 按当前选中品种刷新巡园卡片与作物档案 */
+/** 按当前选中品种刷新巡园卡片(作物档案按农场维度,切品种不重拉) */
 const reloadBySelectedZone = () => {
     resetPatrolList();
     fetchTypesTask();
-    fetchCropArchive();
 };
 
 const loadPatrolData = async () => {
@@ -562,6 +564,7 @@ const handleUploadClick = async (item) => {
     if (uploadChecking.value) return;
     const zoneId = resolveCardZoneId(item);
     uploadZoneId.value = zoneId;
+    uploadCardType.value = item?.type || "";
     uploadChecking.value = true;
     try {
         if (await hasZoneRange(zoneId)) {
@@ -595,7 +598,41 @@ const tryContinueUpload = () => {
     router.replace({ path: route.path, query: restQuery });
 };
 
+/** 异常态势 / 土壤根系:与 abnormalTrack 相同,走巡检上传 */
+const isInspectUploadType = (type) => type === "abnormal" || type === "soil";
+
 const handleUploadConfirm = async ({ images, date } = {}) => {
+    if (isInspectUploadType(uploadCardType.value)) {
+        const imageList = (Array.isArray(images) ? images : [])
+            .filter(Boolean)
+            .map((url) => resolveTaskImage(url));
+        if (!imageList.length) {
+            ElMessage.warning("请先上传照片");
+            return;
+        }
+        const zoneId = uploadZoneId.value || selectedZoneId.value;
+        const { farmId, zoneId: pairedZoneId } = await resolvePairedFarmZone(zoneId);
+        if (farmId == null || pairedZoneId == null || pairedZoneId === "") {
+            ElMessage.warning("当前农场与分区不匹配,请返回后重试");
+            return;
+        }
+        try {
+            const res = await VE_API.pheno.uploadAbnormalPhoto({
+                farm_id: farmId,
+                zone_id: pairedZoneId,
+                images: imageList,
+            });
+            if (res?.code === 200) {
+                showSuccessPopup.value = true;
+                return;
+            }
+            ElMessage.error(res?.msg || "上传失败,请稍后再试");
+        } catch {
+            ElMessage.error("上传失败,请稍后再试");
+        }
+        return;
+    }
+
     const cloud_url = Array.isArray(images) ? images : [];
     if (!cloud_url.length) {
         ElMessage.warning("请先上传照片");
@@ -641,7 +678,7 @@ defineExpose({
 
 <style lang="scss" scoped>
 .patrol-panel {
-    padding-top: 8px;
+    // padding-top: 8px;
     .no-data-text {
         text-align: center;
         padding-top: 40px;

+ 281 - 21
src/views/old_mini/agri_file/components/reportPanel.vue

@@ -1,7 +1,36 @@
 <template>
     <div class="report-panel">
+        <!-- 分区切换 -->
+        <div class="variety-bar">
+            <div class="variety-bar__tags">
+                <div
+                    v-for="item in zoneList"
+                    :key="item.zone_id"
+                    class="variety-bar__tag"
+                    :class="{ active: item.zone_id === selectedZoneId }"
+                    @click="handleSelectZone(item)"
+                >
+                    {{ item.zone_name }}
+                </div>
+            </div>
+        </div>
+
         <!-- 最新报告 -->
         <div class="report-section">
+
+
+            <!-- 报告生成中:status=generating 时展示,并轮询状态 -->
+            <div v-if="showGeneratingCard" class="generating-card">
+                <div class="generating-card__spinner"></div>
+                <div class="generating-card__text">
+                    <div class="generating-card__title">报告生成中</div>
+                    <div class="generating-card__desc">
+                        {{ selectedZoneName || "当前分区" }}
+                        <template v-if="reportGenMessage"> · {{ reportGenMessage }}</template>
+                    </div>
+                </div>
+            </div>
+
             <div class="report-section__title">最新报告</div>
 
             <div
@@ -59,18 +88,8 @@
                 </div>
             </div>
 
-            <div v-if="!latestReports.length" class="report-empty">暂无最新报告</div>
+            <div v-if="!latestReports.length && !showGeneratingCard" class="report-empty">暂无最新报告</div>
 
-            <!-- 报告生成中:暂写死 -->
-            <!-- <div class="generating-card">
-                <div class="generating-card__spinner"></div>
-                <div class="generating-card__text">
-                    <div class="generating-card__title">报告生成中</div>
-                    <div class="generating-card__desc">
-                        东区2号 · 已上传 <span class="generating-card__desc-count">3</span> 张巡园照片
-                    </div>
-                </div>
-            </div> -->
         </div>
 
         <!-- 历史报告 -->
@@ -142,13 +161,21 @@
 </template>
 
 <script setup>
-import { computed, onActivated, onMounted, ref } from "vue";
+import { computed, onActivated, onDeactivated, onUnmounted, ref, watch } from "vue";
 import { useRouter } from "vue-router";
 import { Icon, List } from "vant";
 import { ArrowRight, Clock, Search, WarningFilled } from "@element-plus/icons-vue";
 import { base_img_url2 } from "@/api/config";
 import wx from "weixin-js-sdk";
 
+const props = defineProps({
+    /** 父页切到「诊断报告」时为 true,用于触发重新拉列表 */
+    active: {
+        type: Boolean,
+        default: false,
+    },
+});
+
 const router = useRouter();
 
 const defaultCover = require("@/assets/img/common/sd-1.jpg");
@@ -163,6 +190,19 @@ const TYPE_LABEL_MAP = {
     patrol: "巡园诊断报告",
 };
 
+/** 报告生成状态轮询间隔 */
+const STATUS_POLL_MS = 5000;
+
+// ---------- 页面状态 ----------
+const zoneList = ref([]);
+const selectedZoneId = ref(null);
+const selectedZoneName = ref("");
+
+/** 异常报告生成状态:none / generating / success / failed */
+const reportGenStatus = ref("none");
+const reportGenMessage = ref("");
+const showGeneratingCard = computed(() => reportGenStatus.value === "generating");
+
 // ---------- 最新报告(today_reports,可多份) ----------
 const latestReports = ref([]);
 
@@ -198,6 +238,122 @@ const getSelectedFarm = () => {
     }
 };
 
+const getSelectedFarmId = () => {
+    const farm = getSelectedFarm();
+    const id = farm.farm_id ?? farm.id;
+    return id != null && id !== "" ? Number(id) : null;
+};
+
+// ---------- 业务逻辑:分区 ----------
+const applySelectedZone = (zone) => {
+    selectedZoneId.value = zone?.zone_id ?? null;
+    selectedZoneName.value = zone?.zone_name || "";
+};
+
+/** 记录上次拉分区的农场,切农场时丢弃旧 selectedZoneId */
+let lastZonesFarmId = null;
+
+const fetchZones = async () => {
+    const farmId = getSelectedFarmId();
+    if (farmId == null) {
+        lastZonesFarmId = null;
+        zoneList.value = [];
+        applySelectedZone(null);
+        return;
+    }
+    if (lastZonesFarmId !== farmId) {
+        applySelectedZone(null);
+        lastZonesFarmId = farmId;
+    }
+    try {
+        const res = await VE_API.questionnaire.getZones({ farm_id: farmId });
+        const zones = Array.isArray(res?.data?.zones) ? res.data.zones : [];
+        zoneList.value = zones;
+        const matched = zones.find((z) => z.zone_id === selectedZoneId.value);
+        applySelectedZone(matched || zoneList.value[0] || null);
+    } catch (e) {
+        console.warn("[reportPanel] getZones failed", e);
+        zoneList.value = [];
+        applySelectedZone(null);
+    }
+};
+
+const handleSelectZone = (zone) => {
+    if (!zone || zone.zone_id === selectedZoneId.value) return;
+    applySelectedZone(zone);
+    resetAndLoad();
+};
+
+// ---------- 业务逻辑:报告生成状态 ----------
+let statusPollTimer = null;
+
+const clearStatusPoll = () => {
+    if (statusPollTimer) {
+        clearInterval(statusPollTimer);
+        statusPollTimer = null;
+    }
+};
+
+const startStatusPoll = () => {
+    if (statusPollTimer) return;
+    statusPollTimer = setInterval(() => {
+        fetchReportStatus({ fromPoll: true });
+    }, STATUS_POLL_MS);
+};
+
+/** 仅刷新报告列表(不重复拉生成状态,避免 success 死循环) */
+const reloadReportList = () => {
+    historyList.value = [];
+    historyPage.value = 0;
+    historyFinished.value = false;
+    historyLoading.value = true;
+    latestReports.value = [];
+    historyCount.value = 0;
+    loadHistoryPage();
+};
+
+/**
+ * 查询异常报告生成状态。
+ * none / failed → 不展示;generating → 展示并 5s 轮询;
+ * 轮询中变为 success → 停轮询并重新拉报告列表。
+ */
+const fetchReportStatus = async ({ fromPoll = false } = {}) => {
+    const farmId = getSelectedFarmId();
+    const zoneId = selectedZoneId.value;
+    if (farmId == null || zoneId == null || zoneId === "") {
+        reportGenStatus.value = "none";
+        reportGenMessage.value = "";
+        clearStatusPoll();
+        return;
+    }
+    try {
+        const res = await VE_API.pheno.getAbnormalReportStatus({
+            farm_id: farmId,
+            zone_id: zoneId,
+        });
+        const data = res?.data || {};
+        const status = data.status || "none";
+        reportGenStatus.value = status;
+        reportGenMessage.value = data.message || "";
+
+        if (status === "generating") {
+            startStatusPoll();
+            return;
+        }
+
+        clearStatusPoll();
+        // 仅轮询过程中变为 success 时刷新列表(首屏已是 success 则只隐藏卡片)
+        if (fromPoll && status === "success") {
+            reloadReportList();
+        }
+    } catch (e) {
+        console.warn("[reportPanel] getAbnormalReportStatus failed", e);
+        reportGenStatus.value = "none";
+        reportGenMessage.value = "";
+        clearStatusPoll();
+    }
+};
+
 const resolveCoverUrl = (path) => {
     if (!path) return defaultCover;
     const text = String(path).trim();
@@ -243,6 +399,7 @@ const mapReportItem = (item, index) => {
     const timeInfo = parseReportTime(item.time || item.date);
     return {
         id: item.id ?? `${item.time || ""}-${index}`,
+        taskId: item.task_id || "",
         title: item.title || "",
         type: item.type || "",
         desc: item.content || "",
@@ -259,7 +416,23 @@ const mapReportItem = (item, index) => {
     };
 };
 
+/** diagnosis / patrol 走异常诊断详情,其余仍进预警/胁迫详情 */
+const isDiagnosisReport = (type) => {
+    const key = String(type || "").toLowerCase();
+    return key === "abnormal" || key === "patrol";
+};
+
 const handleReportClick = (item) => {
+    if (isDiagnosisReport(item?.type)) {
+        router.push({
+            path: "/abnormal_diagnosis_report",
+            query: {
+                task_id: item?.taskId || "",
+                title: item?.title || "诊断报告",
+            },
+        });
+        return;
+    }
     router.push({
         path: "/alert_detail",
         query: {
@@ -270,7 +443,25 @@ const handleReportClick = (item) => {
 };
 
 const handleShare = (item) => {
-    const shareText = item?.type === 'warning' ? '预警报告已生成,请点击查看吧!' : '胁迫报告已生成,请点击查看吧!';
+    if (isDiagnosisReport(item?.type)) {
+        const query = {
+            askInfo: { title: "转发报告", content: "是否分享给好友" },
+            shareText: "诊断报告已生成,请点击查看吧!",
+            targetUrl: "abnormal_diagnosis_report",
+            paramsPage: JSON.stringify({
+                task_id: item?.taskId || "",
+                title: item?.title || "诊断报告",
+                fromShare: 1,
+            }),
+            imageUrl: "https://birdseye-img.sysuimars.com/farm-h5/report_cover.png",
+        };
+        wx.miniProgram.navigateTo({
+            url: `/pages/subPages/share_page/index?pageParams=${JSON.stringify(query)}&type=sharePage`,
+        });
+        return;
+    }
+
+    const shareText = item?.type === "warning" ? "预警报告已生成,请点击查看吧!" : "胁迫报告已生成,请点击查看吧!";
     const query = {
         askInfo: { title: "转发报告", content: "是否分享给好友" },
         shareText,
@@ -292,10 +483,9 @@ const handleShare = (item) => {
  * 由 van-list 的 @load 在滚动到底部时持续触发。
  */
 const loadHistoryPage = async () => {
-    const farm = getSelectedFarm();
-    const farmId = farm.farm_id ?? farm.id;
-    const zoneId = farm.zone_id ?? farm.zoneId;
-    if (farmId == null || farmId === "" || zoneId == null || zoneId === "") {
+    const farmId = getSelectedFarmId();
+    const zoneId = selectedZoneId.value;
+    if (farmId == null || zoneId == null || zoneId === "") {
         historyFinished.value = true;
         historyLoading.value = false;
         return;
@@ -333,8 +523,11 @@ const loadHistoryPage = async () => {
     }
 };
 
-/** 进入 / 再次激活:重置分页并由 van-list 触发首屏加载 */
+/** 进入 / 再次激活:重置分页并拉取报告列表 + 生成状态 */
 const resetAndLoad = () => {
+    clearStatusPoll();
+    reportGenStatus.value = "none";
+    reportGenMessage.value = "";
     historyList.value = [];
     historyPage.value = 0;
     historyFinished.value = false;
@@ -342,14 +535,81 @@ const resetAndLoad = () => {
     latestReports.value = [];
     historyCount.value = 0;
     loadHistoryPage();
+    fetchReportStatus();
 };
 
-onMounted(resetAndLoad);
-onActivated(resetAndLoad);
+/** 先拉分区再加载报告列表 */
+const initPanel = async () => {
+    await fetchZones();
+    resetAndLoad();
+};
+
+onActivated(initPanel);
+onDeactivated(clearStatusPoll);
+onUnmounted(clearStatusPoll);
+
+/** v-show 切 tab 不会触发 onActivated,靠 active 每次进入都重新请求 */
+watch(
+    () => props.active,
+    (active) => {
+        if (active) initPanel();
+    },
+);
 </script>
 
 <style lang="scss" scoped>
 .report-panel {
+    .variety-bar {
+        display: flex;
+        align-items: center;
+        justify-content: space-between;
+        gap: 12px;
+        margin-bottom: 12px;
+
+        &__tags {
+            display: flex;
+            align-items: center;
+            flex-wrap: nowrap;
+            gap: 16px;
+            flex: 1;
+            min-width: 0;
+            overflow-x: auto;
+            -webkit-overflow-scrolling: touch;
+            scrollbar-width: none;
+
+            &::-webkit-scrollbar {
+                display: none;
+            }
+        }
+
+        &__tag {
+            position: relative;
+            flex: none;
+            white-space: nowrap;
+            padding: 4px 0 8px;
+            color: rgba(255, 255, 255, 0.35);
+            font-size: 14px;
+            line-height: 20px;
+
+            &.active {
+                color: #ffd489;
+                font-weight: 500;
+
+                &::after {
+                    content: "";
+                    position: absolute;
+                    left: 50%;
+                    bottom: 0;
+                    transform: translateX(-50%);
+                    width: 100%;
+                    height: 2px;
+                    border-radius: 2px;
+                    background: #ffd489;
+                }
+            }
+        }
+    }
+
     .report-section--history {
         margin-top: 10px;
     }
@@ -606,7 +866,7 @@ onActivated(resetAndLoad);
 
     // ---------- 报告生成中 ----------
     .generating-card {
-        margin-top: 10px;
+        margin: 10px 0;
         padding: 14px;
         border-radius: 12px;
         border: 1px dashed rgba(255, 255, 255, 0.2);

+ 1 - 1
src/views/old_mini/agri_file/index.vue

@@ -37,7 +37,7 @@
                 :active="activeNav === 'album'"
                 @open-upload="openUploadPopup"
             />
-            <report-panel v-show="activeNav === 'report'" />
+            <report-panel v-show="activeNav === 'report'" :active="activeNav === 'report'" />
         </div>
         <album-upload-popup v-model:show="showUploadPopup" @confirm="handleUploadConfirm" />
         <tip-popup v-model:show="showSuccessPopup" type="executeSuccess" text="您已上传成功" text2="诊断报告正在生成,请稍后..." hideBtn>

+ 81 - 16
src/views/old_mini/agri_file/pages/abnormalTrack.vue

@@ -153,6 +153,20 @@
                 </div>
             </template>
         </tip-popup>
+        <tip-popup
+            v-model:show="showInteractSuccessPopup"
+            type="executeSuccess"
+            :text="interactSuccessText"
+            :text2="interactSuccessText2"
+            hideBtn
+        >
+            <template #footer>
+                <div class="bottom-btn-container">
+                    <div class="bottom-btn secondary-btn" @click="handleInteractComplete">完成</div>
+                    <div class="bottom-btn primary-btn" @click="handleViewWorkDetail">查看详情</div>
+                </div>
+            </template>
+        </tip-popup>
     </div>
 </template>
 
@@ -193,6 +207,15 @@ const loading = ref(false);
 const submitting = ref(false);
 const showUploadPopup = ref(false);
 const showSuccessPopup = ref(false);
+const showInteractSuccessPopup = ref(false);
+/** 异常确认成功弹窗:文案与跳转参数来自接口 farmwork_brief */
+const interactSuccessBrief = ref({
+    fw_name: "",
+    suggest_execute_date: "",
+    farm_id: null,
+    zone_id: null,
+    fw_code: "",
+});
 const needDraw = ref(true); // status≠1 时需先勾画种植范围
 const interactList = ref([]); // ab_it_info.interact_Info 映射后的列表
 const stressInfo = ref({}); // 胁迫等级等公共信息
@@ -206,6 +229,15 @@ const queryContext = ref({
     crop_type: "",
 });
 
+const interactSuccessText = computed(() => {
+    const name = interactSuccessBrief.value.fw_name || "";
+    return `系统已触发了 ${name}农事`;
+});
+const interactSuccessText2 = computed(() => {
+    const date = interactSuccessBrief.value.suggest_execute_date || "";
+    return `建议 ${date} 执行`;
+});
+
 // ---------- 工具函数 ----------
 function isTruthyFlag(value) {
     return value === 1 || value === "1" || value === true || value === "true";
@@ -455,26 +487,24 @@ const handleUploadClick = () => {
     showUploadPopup.value = true;
 };
 
-const handleUploadConfirm = async ({ images, date } = {}) => {
-    const cloud_url = Array.isArray(images) ? images : [];
-    if (!cloud_url.length) {
+const handleUploadConfirm = async ({ images } = {}) => {
+    const imageList = (Array.isArray(images) ? images : [])
+        .filter(Boolean)
+        .map((url) => resolveImageUrl(url));
+    if (!imageList.length) {
         ElMessage.warning("请先上传照片");
         return;
     }
-    const farm = getSelectedFarm();
     const { farmId, zoneId: pairedZoneId } = await resolvePairedFarmZone(zoneId.value);
     if (farmId == null || pairedZoneId == null || pairedZoneId === "") {
         ElMessage.warning("当前农场与分区不匹配,请返回后重试");
         return;
     }
     try {
-        const res = await VE_API.questionnaire.uploadImages({
-            cloud_url,
+        const res = await VE_API.pheno.uploadAbnormalPhoto({
             farm_id: farmId,
             zone_id: pairedZoneId,
-            category_code: farm.category_code || "",
-            zone_name: farm.variety_name || "",
-            create_time: date,
+            images: imageList,
         });
         if (res?.code === 200) {
             showSuccessPopup.value = true;
@@ -491,6 +521,27 @@ const handleComplete = () => {
     router.replace("/agri_file");
 };
 
+const handleInteractComplete = () => {
+    showInteractSuccessPopup.value = false;
+};
+
+const handleViewWorkDetail = () => {
+    const { farm_id, zone_id, fw_code } = interactSuccessBrief.value;
+    showInteractSuccessPopup.value = false;
+    if (farm_id == null || zone_id == null || !fw_code) {
+        ElMessage.warning("农事信息不完整,无法查看详情");
+        return;
+    }
+    router.push({
+        path: "/work_detail",
+        query: {
+            farm_id,
+            zone_id,
+            fw_code,
+        },
+    });
+};
+
 const handleSubmit = async (item, index) => {
     const key = interactKey(item, index);
     const optIndex = selectedMap[key];
@@ -512,9 +563,18 @@ const handleSubmit = async (item, index) => {
             options: String(optionText),
         });
         if (res?.code === 200) {
-            ElMessage.success(t("agriFile.submitSuccess"));
+            const data = res?.data || {};
+            const brief = data.farmwork_brief || {};
+            interactSuccessBrief.value = {
+                fw_name: brief.fw_name || "",
+                suggest_execute_date: brief.suggest_execute_date || "",
+                farm_id: data.farm_id ?? queryContext.value.farm_id,
+                zone_id: data.zone_id ?? queryContext.value.zone_id,
+                fw_code: brief.fw_code || data.fw_code || "",
+            };
             editingMap[key] = false;
             await fetchAbnormalInteract();
+            showInteractSuccessPopup.value = true;
             return;
         }
         ElMessage.error(res?.msg || "提交失败,请稍后再试");
@@ -1035,19 +1095,24 @@ onActivated(async () => {
     width: 100%;
 
     .bottom-btn {
+        flex: 1;
         padding: 0 25px;
         border-radius: 8px;
         font-size: 16px;
-        height: 40px;
-        line-height: 40px;
+        height: 44px;
+        line-height: 44px;
         box-sizing: border-box;
-        font-weight: 500;
         text-align: center;
 
+        &.secondary-btn {
+            color: rgba(255, 255, 255, 0.6);
+            border: 1px solid rgba(255, 255, 255, 0.12);
+            background: transparent;
+        }
+
         &.primary-btn {
-            flex: 1;
-            background: linear-gradient(90deg, #ffebc9 0%, #ffca6d 100%);
-            color: #1a1408;
+            background: linear-gradient(90deg, #FFEBC9 0%, #FFCA6D 100%);
+            color: #1A1408;
         }
     }
 }

+ 699 - 0
src/views/old_mini/agri_file/pages/abnormal_diagnosis_report.vue

@@ -0,0 +1,699 @@
+<template>
+    <div class="abnormal-diagnosis-page">
+        <custom-header
+            :name="pageTitle"
+            :isClose="isFromShare"
+            :showClose="false"
+        />
+        <div class="abnormal-diagnosis-body" v-loading="loading">
+            <div class="abnormal-diagnosis-content">
+                <!-- 综合研判 + 作物摘要 -->
+                <div v-if="summary.conclusion || summary.cropName" class="analysis-top">
+                    <div class="analysis-card">
+                        <div class="analysis-card__content">
+                            <div class="section-title section-title--pill">综合研判</div>
+                            <div v-if="summary.conclusion" class="section-desc">
+                                {{ summary.conclusion }}
+                            </div>
+                        </div>
+                    </div>
+
+                    <div v-if="summary.cropName || summary.rows.length" class="crop-panel">
+                        <div class="crop-panel__content">
+                            <div class="crop-panel__head">
+                                <img class="crop-panel__cover" :src="summary.cover" alt="" />
+                                <span class="crop-panel__name">{{ summary.cropName }}</span>
+                                <span v-if="summary.badge" class="crop-panel__tag">当前作物</span>
+                            </div>
+                            <div v-if="summary.rows.length" class="crop-panel__list">
+                                <div
+                                    v-for="item in summary.rows"
+                                    :key="item.key || item.label"
+                                    class="crop-metric"
+                                >
+                                    <img class="crop-metric__icon" :src="item.icon" alt="" />
+                                    <div class="crop-metric__content">
+                                        <div class="crop-metric__label">{{ item.label }}</div>
+                                        <div class="crop-metric__value">{{ item.value }}</div>
+                                    </div>
+                                </div>
+                            </div>
+                        </div>
+                    </div>
+                </div>
+
+                <!-- panels:巡园结果 / 影响分析 / 农事建议 -->
+                <div
+                    v-for="panel in panels"
+                    :key="panel.key"
+                    class="timeline-section"
+                >
+                    <div class="timeline-section__head">
+                        <span class="timeline-section__dot"></span>
+                        <span class="timeline-section__title">{{ panel.title }}</span>
+                    </div>
+
+                    <!-- 巡园结果:左图 + tag + content -->
+                    <div v-if="panel.key === 'inspection'" class="patrol-list">
+                        <div
+                            v-for="item in panel.items"
+                            :key="item.id"
+                            class="patrol-item"
+                        >
+                            <img
+                                v-if="item.cover"
+                                class="patrol-item__cover"
+                                :src="item.cover"
+                                alt=""
+                            />
+                            <div class="patrol-item__body">
+                                <div class="patrol-item__title">{{ item.tag || item.title }}</div>
+                                <div class="patrol-item__desc">{{ item.content }}</div>
+                            </div>
+                        </div>
+                    </div>
+
+                    <!-- 表现影响:tag 角标 + title + content -->
+                    <div v-else-if="panel.key === 'impact'" class="diag-list">
+                        <div
+                            v-for="item in panel.items"
+                            :key="item.id"
+                            class="diag-item"
+                        >
+                            <span v-if="item.tag" class="diag-item__tag">{{ item.tag }}</span>
+                            <div v-if="item.title" class="diag-item__title">{{ item.title }}</div>
+                            <div v-if="item.content" class="diag-item__desc">{{ item.content }}</div>
+                        </div>
+                    </div>
+
+                    <!-- 农事建议:同一卡片内编号列表 -->
+                    <div v-else-if="panel.key === 'farmwork'" class="advice-card">
+                        <div
+                            v-for="item in panel.items"
+                            :key="item.id"
+                            class="advice-item"
+                        >
+                            <div class="advice-item__title">
+                                <span class="advice-item__index">{{ item.index }}</span>
+                                <span>{{ item.title }}</span>
+                            </div>
+                            <div class="advice-item__desc">{{ item.content }}</div>
+                        </div>
+                    </div>
+
+                    <!-- 兜底:按 impact 卡片样式 -->
+                    <div v-else class="diag-list">
+                        <div
+                            v-for="item in panel.items"
+                            :key="item.id"
+                            class="diag-item"
+                        >
+                            <span v-if="item.tag" class="diag-item__tag">{{ item.tag }}</span>
+                            <div v-if="item.title" class="diag-item__title">{{ item.title }}</div>
+                            <div v-if="item.content" class="diag-item__desc">{{ item.content }}</div>
+                        </div>
+                    </div>
+                </div>
+
+                <div v-if="!loading && !hasContent" class="empty-tip">暂无诊断报告</div>
+            </div>
+
+            <div v-if="hasContent" class="share-btn" @click="handleShare">
+                <div class="share-btn__text">{{ footerAction }}</div>
+            </div>
+        </div>
+    </div>
+</template>
+
+<script setup>
+import { computed, onMounted, ref } from "vue";
+import { useRoute } from "vue-router";
+import customHeader from "@/components/customHeader.vue";
+import { resolveCropIcon } from "@/utils/cropIcon";
+import wx from "weixin-js-sdk";
+
+// ---------- 常量 ----------
+const ICON_MAP = {
+    phenophase: require("@/assets/img/common/header-icon-3.png"),
+    weather: require("@/assets/img/common/header-icon-1.png"),
+    soil: require("@/assets/img/common/header-icon-2.png"),
+};
+const defaultCropCover = require("@/assets/img/home/plant.png");
+
+// ---------- 页面状态 ----------
+const route = useRoute();
+const loading = ref(false);
+const pageTitle = ref("诊断报告");
+const footerAction = ref("转发报告");
+const summary = ref({
+    conclusion: "",
+    cropName: "",
+    badge: "",
+    cover: defaultCropCover,
+    rows: [],
+});
+const panels = ref([]);
+
+// ---------- 计算属性 ----------
+const isFromShare = computed(() => {
+    if (isTruthyFlag(route.query.fromShare)) return true;
+    const paramsPage = parseMaybeJson(route.query.paramsPage);
+    if (isTruthyFlag(paramsPage?.fromShare)) return true;
+    const miniJson = parseMaybeJson(route.query.miniJson);
+    if (isTruthyFlag(miniJson?.fromShare)) return true;
+    if (isTruthyFlag(parseMaybeJson(miniJson?.paramsPage)?.fromShare)) return true;
+    return false;
+});
+
+const hasContent = computed(
+    () => Boolean(summary.value.conclusion || summary.value.cropName || panels.value.length),
+);
+
+// ---------- 工具函数 ----------
+function isTruthyFlag(value) {
+    return value === 1 || value === "1" || value === true || value === "true";
+}
+
+function parseMaybeJson(value) {
+    if (value == null || value === "") return null;
+    if (typeof value === "object") return value;
+    try {
+        return JSON.parse(value);
+    } catch {
+        return null;
+    }
+}
+
+/** 分享落地可能把参数塞在 paramsPage / miniJson 里 */
+const resolveQueryBag = () => {
+    const paramsPage = parseMaybeJson(route.query.paramsPage) || {};
+    const miniJson = parseMaybeJson(route.query.miniJson) || {};
+    const nested = parseMaybeJson(miniJson.paramsPage) || {};
+    return { ...nested, ...paramsPage, ...route.query };
+};
+
+const getTaskId = () => {
+    const q = resolveQueryBag();
+    const taskId = q.task_id;
+    return taskId != null && String(taskId).trim() !== "" ? String(taskId) : "";
+};
+
+const resolveRowIcon = (iconKey) => ICON_MAP[iconKey] || ICON_MAP.phenophase;
+
+const padIndex = (index, fallback) => {
+    if (index != null && String(index).trim() !== "") return String(index);
+    return String(fallback).padStart(2, "0");
+};
+
+const mapPanelItems = (items = []) =>
+    (Array.isArray(items) ? items : []).map((item, index) => {
+        const images = Array.isArray(item.images) ? item.images : [];
+        const cover = images[0]?.cloud_url || "";
+        return {
+            id: `${item.index || index}-${item.title || item.tag || index}`,
+            index: padIndex(item.index, index + 1),
+            tag: item.tag || "",
+            title: item.title || "",
+            content: item.content || "",
+            cover,
+        };
+    });
+
+/** 把单份 report.view 灌入页面状态 */
+const applyReport = (report) => {
+    if (!report) return;
+    const view = report.view || {};
+    const viewSummary = view.summary || {};
+    const cropName = viewSummary.crop_name || report.crop_name || "";
+
+    pageTitle.value = view.title || "诊断报告";
+    footerAction.value = view.footer?.action || "转发报告";
+
+    summary.value = {
+        conclusion: viewSummary.conclusion || report.interact_explain || "",
+        cropName,
+        badge: viewSummary.badge || "",
+        cover: resolveCropIcon(cropName, defaultCropCover),
+        rows: (Array.isArray(viewSummary.rows) ? viewSummary.rows : [])
+            .map((row) => ({
+                key: row.key || row.icon || row.label,
+                label: row.label || "",
+                value: row.value || "",
+                icon: resolveRowIcon(row.icon || row.key),
+            }))
+            .filter((row) => row.value),
+    };
+
+    panels.value = (Array.isArray(view.panels) ? view.panels : [])
+        .map((panel) => ({
+            key: panel.key || "",
+            title: panel.title || "",
+            items: mapPanelItems(panel.items),
+        }))
+        .filter((panel) => panel.items.length);
+};
+
+// ---------- 业务逻辑 ----------
+const fetchDetail = async () => {
+    const taskId = getTaskId();
+    if (!taskId) return;
+
+    loading.value = true;
+    try {
+        const res = await VE_API.pheno.getAbnormalAnalysisReport({
+            task_id: taskId,
+        });
+        const data = res?.data || {};
+        const reports = Array.isArray(data.reports) ? data.reports : [];
+        applyReport(reports[0] || null);
+    } catch (e) {
+        console.warn("[abnormal_diagnosis_report] fetch failed", e);
+    } finally {
+        loading.value = false;
+    }
+};
+
+const handleShare = () => {
+    const query = {
+        askInfo: { title: "转发报告", content: "是否分享给好友" },
+        shareText: "诊断报告已生成,请点击查看吧!",
+        targetUrl: "abnormal_diagnosis_report",
+        paramsPage: JSON.stringify({
+            task_id: getTaskId(),
+            title: pageTitle.value || "诊断报告",
+            fromShare: 1,
+        }),
+        imageUrl: "https://birdseye-img.sysuimars.com/farm-h5/report_cover.png",
+    };
+    wx.miniProgram.navigateTo({
+        url: `/pages/subPages/share_page/index?pageParams=${JSON.stringify(query)}&type=sharePage`,
+    });
+};
+
+// ---------- 生命周期 ----------
+onMounted(() => {
+    const q = resolveQueryBag();
+    if (q.title) pageTitle.value = String(q.title);
+    fetchDetail();
+});
+</script>
+
+<style lang="scss" scoped>
+.abnormal-diagnosis-page {
+    min-height: 100vh;
+    background: #0b0b0b;
+    color: #fff;
+}
+
+.abnormal-diagnosis-body {
+    box-sizing: border-box;
+    overflow-y: auto;
+    height: calc(100vh - 40px - env(safe-area-inset-bottom));
+    display: flex;
+    flex-direction: column;
+
+    .abnormal-diagnosis-content {
+        flex: 1;
+        padding: 24px 12px 10px;
+        overflow-y: auto;
+    }
+
+    .share-btn {
+        flex-shrink: 0;
+    }
+
+    :deep(.el-loading-mask) {
+        background-color: rgba(11, 11, 11, 0.7);
+    }
+}
+
+.analysis-top {
+    margin-bottom: 16px;
+}
+
+.analysis-card {
+    padding: 1px;
+    border-radius: 12px;
+    background: linear-gradient(180deg, rgba(255, 255, 255, 0.2) 0%, rgba(255, 255, 255, 0) 72.15%);
+
+    &__content {
+        padding: 11px 13px;
+        border-radius: 12px;
+        background: linear-gradient(180deg, #1a191d 0%, #121216 100%);
+        box-sizing: border-box;
+    }
+}
+
+.section-title {
+    font-size: 16px;
+    font-weight: 500;
+    line-height: 24px;
+    color: #f2e9d8;
+
+    &--pill {
+        display: flex;
+        align-items: center;
+        gap: 8px;
+
+        &::before {
+            content: "";
+            width: 4px;
+            height: 16px;
+            border-radius: 2px;
+            background: #ffd489;
+            flex-shrink: 0;
+        }
+    }
+}
+
+.section-desc {
+    margin-top: 10px;
+    font-size: 14px;
+    line-height: 22px;
+    color: rgba(255, 255, 255, 0.55);
+    word-break: break-all;
+    text-align: justify;
+    font-weight: 350;
+    white-space: pre-line;
+}
+
+.crop-panel {
+    margin-top: 12px;
+    border-radius: 12px;
+    padding: 1px;
+    box-sizing: border-box;
+    background: linear-gradient(180deg, rgba(255, 212, 137, 0.4) 0%, rgba(255, 212, 137, 0) 72.15%);
+
+    .crop-panel__content {
+        padding: 10px 12px;
+        border-radius: 12px;
+        background: rgba(26, 24, 20, 1);
+    }
+
+    &__head {
+        display: flex;
+        align-items: center;
+        gap: 8px;
+        padding-bottom: 14px;
+        border-bottom: 1px solid rgba(255, 255, 255, 0.06);
+    }
+
+    &__cover {
+        width: 40px;
+        height: 40px;
+        border-radius: 50%;
+        object-fit: cover;
+        flex-shrink: 0;
+        border: 1px solid rgba(255, 212, 137, 0.5);
+        background: rgba(255, 255, 255, 0.08);
+    }
+
+    &__name {
+        font-size: 18px;
+        color: #fff;
+    }
+
+    &__tag {
+        padding: 0 6px;
+        border-radius: 3px;
+        background: rgba(255, 212, 137, 0.1);
+        border: 1px solid rgba(255, 212, 137, 0.16);
+        color: #ffd489;
+        font-size: 12px;
+        height: 19px;
+        line-height: 19px;
+        flex-shrink: 0;
+        box-sizing: border-box;
+    }
+
+    &__list {
+        display: flex;
+        flex-direction: column;
+    }
+}
+
+.crop-metric {
+    display: flex;
+    align-items: flex-start;
+    gap: 8px;
+    padding-top: 14px;
+
+    &:last-child {
+        .crop-metric__content {
+            border-bottom: none;
+        }
+    }
+
+    &__icon {
+        width: 16px;
+        height: 16px;
+        flex-shrink: 0;
+        object-fit: contain;
+        filter: brightness(0) invert(0.7);
+        margin-top: 3px;
+        opacity: 0.85;
+    }
+
+    &__content {
+        flex: 1;
+        min-width: 0;
+        font-size: 14px;
+        line-height: 22px;
+        padding-bottom: 10px;
+        word-break: break-all;
+        border-bottom: 1px solid rgba(255, 255, 255, 0.06);
+    }
+
+    &__label {
+        color: rgba(255, 255, 255, 0.6);
+    }
+
+    &__value {
+        padding-top: 3px;
+        color: rgba(255, 255, 255, 0.9);
+    }
+}
+
+.timeline-section {
+    position: relative;
+    padding-bottom: 20px;
+    padding-left: 18px;
+
+    &::before {
+        content: "";
+        position: absolute;
+        left: 6px;
+        top: 19px;
+        bottom: 0;
+        width: 1px;
+        background: linear-gradient(180deg, rgba(255, 212, 137, 0.45) 0%, rgba(255, 212, 137, 0.12) 100%);
+    }
+
+    &:last-of-type::before {
+        bottom: 12px;
+    }
+
+    &__head {
+        position: relative;
+        display: flex;
+        align-items: center;
+        gap: 10px;
+        margin-bottom: 12px;
+        margin-left: -18px;
+    }
+
+    &__dot {
+        width: 14px;
+        height: 14px;
+        border-radius: 50%;
+        border: 1px solid rgba(255, 212, 137, 0.3);
+        box-sizing: border-box;
+        flex-shrink: 0;
+        position: relative;
+        z-index: 1;
+        &::after {
+            content: "";
+            position: absolute;
+            left: 50%;
+            top: 50%;
+            transform: translate(-50%, -50%);
+            width: 7px;
+            height: 7px;
+            background: #FFD489;
+            border-radius: 50%;
+        }
+    }
+
+    &__title {
+        font-size: 16px;
+        font-weight: 500;
+        line-height: 24px;
+        color: #ffd489;
+    }
+}
+
+.patrol-list {
+    display: flex;
+    flex-direction: column;
+    gap: 10px;
+}
+
+.patrol-item {
+    display: flex;
+    align-items: flex-start;
+    gap: 10px;
+    background: rgba(255, 255, 255, 0.04);
+    padding: 10px;
+    border-radius: 10px;
+    border: 1px solid rgba(255, 255, 255, 0.06);
+    box-sizing: border-box;
+
+    &__cover {
+        width: 100px;
+        height: 86px;
+        border-radius: 6px;
+        object-fit: cover;
+        flex-shrink: 0;
+        background: rgba(255, 255, 255, 0.06);
+    }
+
+    &__body {
+        flex: 1;
+        min-width: 0;
+    }
+
+    &__title {
+        font-size: 14px;
+        font-weight: 500;
+        line-height: 22px;
+        color: #fff;
+    }
+
+    &__desc {
+        margin-top: 4px;
+        font-size: 12px;
+        line-height: 20px;
+        color: rgba(255, 255, 255, 0.5);
+        word-break: break-all;
+        text-align: justify;
+        display: -webkit-box;
+        -webkit-line-clamp: 4;
+        -webkit-box-orient: vertical;
+        overflow: hidden;
+    }
+}
+
+.diag-list {
+    display: flex;
+    flex-direction: column;
+    gap: 10px;
+}
+
+.diag-item {
+    padding: 12px;
+    border-radius: 10px;
+    background: rgba(255, 255, 255, 0.05);
+    border: 1px solid rgba(255, 255, 255, 0.06);
+    box-sizing: border-box;
+
+    &__tag {
+        display: inline-block;
+        padding: 0 8px;
+        height: 22px;
+        line-height: 20px;
+        border-radius: 3px;
+        background: rgba(255, 212, 137, 0.08);
+        border: 1px solid rgba(255, 212, 137, 0.5);
+        color: #ffd489;
+        font-size: 12px;
+        box-sizing: border-box;
+    }
+
+    &__title {
+        margin-top: 8px;
+        font-size: 15px;
+        font-weight: 500;
+        line-height: 22px;
+        color: #fff;
+    }
+
+    &__desc {
+        margin-top: 6px;
+        font-size: 13px;
+        line-height: 20px;
+        color: rgba(255, 255, 255, 0.5);
+        word-break: break-all;
+        text-align: justify;
+    }
+}
+
+.advice-card {
+    padding: 2px 4px;
+    border-radius: 10px;
+    background: rgba(255, 255, 255, 0.04);
+    border: 1px solid rgba(255, 255, 255, 0.06);
+    box-sizing: border-box;
+}
+
+.advice-item {
+    padding: 14px 10px;
+    box-sizing: border-box;
+
+    & + & {
+        border-top: 1px solid rgba(255, 255, 255, 0.08);
+    }
+
+    &__title {
+        display: flex;
+        align-items: flex-start;
+        gap: 8px;
+        font-size: 14px;
+        line-height: 22px;
+        color: #fff;
+    }
+
+    &__index {
+        color: #ffd489;
+        font-size: 15px;
+        font-weight: 600;
+        line-height: 22px;
+        flex-shrink: 0;
+        font-variant-numeric: tabular-nums;
+    }
+
+    &__desc {
+        margin-top: 6px;
+        margin-left: 30px;
+        font-size: 12px;
+        line-height: 20px;
+        color: rgba(255, 255, 255, 0.5);
+        word-break: break-all;
+        white-space: pre-line;
+        text-align: justify;
+    }
+}
+
+.empty-tip {
+    padding: 48px 0;
+    text-align: center;
+    font-size: 14px;
+    color: rgba(255, 255, 255, 0.45);
+}
+
+.share-btn {
+    padding-top: 6px;
+    border-top: 1px solid rgba(255, 255, 255, 0.06);
+    background: rgba(18, 18, 20, 1);
+
+    .share-btn__text {
+        margin: 0 12px calc(22px + env(safe-area-inset-bottom)) 12px;
+        border-radius: 10px;
+        background: linear-gradient(90deg, #ffebc9 0%, #ffca6d 100%);
+        width: calc(100% - 24px);
+        height: 44px;
+        color: #000;
+        line-height: 44px;
+        text-align: center;
+    }
+}
+</style>

+ 4 - 2
src/views/old_mini/agri_file/pages/diagnosisReport.vue

@@ -1173,11 +1173,13 @@ onBeforeUnmount(() => {
                 line-height: 18px;
                 white-space: nowrap;
                 color: rgba(255, 255, 255, 0.45);
+                border: 1px solid transparent;
                 cursor: pointer;
 
                 &.active {
-                    background: rgba(255, 255, 255, 0.12);
-                    color: #fff;
+                    border: 1px solid rgba(255, 212, 137, 0.12);
+                    background: rgba(255, 212, 137, 0.1);
+                    color: #FFD489;
                     font-weight: 500;
                 }
             }

+ 7 - 9
src/views/old_mini/agri_file/pages/soilRootTrack.vue

@@ -560,26 +560,24 @@ const handleUploadClick = () => {
     showUploadPopup.value = true;
 };
 
-const handleUploadConfirm = async ({ images, date } = {}) => {
-    const cloud_url = Array.isArray(images) ? images : [];
-    if (!cloud_url.length) {
+const handleUploadConfirm = async ({ images } = {}) => {
+    const imageList = (Array.isArray(images) ? images : [])
+        .filter(Boolean)
+        .map((url) => resolveImageUrl(url));
+    if (!imageList.length) {
         ElMessage.warning("请先上传照片");
         return;
     }
-    const farm = getSelectedFarm();
     const { farmId, zoneId: pairedZoneId } = await resolvePairedFarmZone(zoneId.value);
     if (farmId == null || pairedZoneId == null || pairedZoneId === "") {
         ElMessage.warning("当前农场与分区不匹配,请返回后重试");
         return;
     }
     try {
-        const res = await VE_API.questionnaire.uploadImages({
-            cloud_url,
+        const res = await VE_API.pheno.uploadAbnormalPhoto({
             farm_id: farmId,
             zone_id: pairedZoneId,
-            category_code: farm.category_code || "",
-            zone_name: farm.variety_name || "",
-            create_time: date,
+            images: imageList,
         });
         if (res?.code === 200) {
             showSuccessPopup.value = true;