Parcourir la source

fix: 切换分区

lxf il y a 4 jours
Parent
commit
59064614d3

+ 37 - 2
src/components/pageComponents/ArchivesFarmTimeLine.vue

@@ -60,7 +60,7 @@
                                             </div>
                                         </div>
                                         <div class="title-wrap van-ellipsis" v-if="fw.flowStatus != null && fw.flowStatus != 0 && fw.flowStatus != -2">
-                                            <div class="title-text">{{ flowStatusStr[fw.flowStatus] }}</div>
+                                            <div class="title-text">{{ handleTagType(fw.flowStatus, fw.executeEvidenceAuditStatus) }}</div>
                                             <div class="title-text blue-tag" v-if="fw?.executionLimitDays >= 0">限时溯源</div>
                                         </div>
                                     </div>
@@ -576,9 +576,10 @@ const getArrangeStatusClass = (fw) => {
     const t = props.pageType === 'agri_record' ? fw?.flowStatus : fw?.sourceType;
     if (props.pageType === 'agri_record') {
         if (t == null || t == 0 || t == -2) return "status-default";
+        const status = getAuditStatusPriority(fw.executeEvidenceAuditStatus);
         // 农事记录:内容仍用 status-warning 的红字/红标签,外边框与箭头改为灰色
         if (t == -1) return "status-warning status-warning-agri-record";
-        if (t == 3) return "status-warning-bg";
+        if (t == 3 || status === 2 || status === 0) return "status-warning-bg";
         if (t == 5) return "status-normal";
         return "status-act";
     } else {
@@ -977,6 +978,40 @@ const flowStatusStr = {
     '5': '已认证',
 }
 
+const handleTagType = (tagType, executeEvidenceAuditStatus) => {
+    if (tagType == 0) return "待触发";
+    if (tagType == -1) return "已过期";
+    if (tagType == -2) return "已过期";
+    if (tagType == 3) {
+        const status = getAuditStatusPriority(executeEvidenceAuditStatus);
+        if (status === 2) {
+            return "审核失败";
+        }
+        return "待认证"
+    }
+    if (tagType == 5) {
+        const status = getAuditStatusPriority(executeEvidenceAuditStatus);
+        if (status === 2) {
+            return "审核失败";
+        }
+        if (status === 0) {
+            return "审核中";
+        }
+        return "已认证";
+    }
+    return "待触发"
+}
+
+// 审核状态优先级:2 > 0 > 1
+const getAuditStatusPriority = (auditStatusList) => {
+    if (!Array.isArray(auditStatusList) || !auditStatusList.length) return 1;
+    const normalized = auditStatusList.map((x) => Number(x)).filter((x) => [0, 1, 2].includes(x));
+    if (!normalized.length) return 1;
+    if (normalized.includes(0)) return 0;
+    if (normalized.includes(2)) return 2;
+    return 1;
+};
+
 // 右侧农事卡片展示用日期(与模板 left-date 一致:规划 createTime、记录 recommendDate)
 const getFarmWorkTimelineDateMs = (fw) => {
     const primary = props.pageType === "agri_plan" ? fw?.createTime : fw?.recommendDate ?? fw?.createTime;

+ 2 - 0
src/views/old_mini/agri_record/index.vue

@@ -134,6 +134,8 @@ const handleVarietyClick = (tab, index) => {
         farmIdData.value = tab.farmId;
         containerData.value = tab.containerId;
         regionData.value = tab.regionId;
+    } else {
+        regionData.value = null;
     }
     currentVariety.value = tab;
     if (tab.lastViewTime == null && tab.regionId) {

+ 51 - 34
src/views/old_mini/growth_report/index.vue

@@ -5,15 +5,16 @@
         <!-- 组件:天气 -->
         <weather-info ref="weatherInfoRef" from="growth_report" class="weather-info" @weatherExpanded="weatherExpanded"
             @changeGarden="changeGarden" :isGarden="true"></weather-info>
-        <div class="report-content-wrap" v-if="hasReport" v-loading="loading" element-loading-background="rgba(0, 0, 0, 0.1)">
-          <div class="history-risk-report-btn" @click="handleHistoryRiskReportClick">
-            <span class="risk-report-icon">
-              <i></i>
-            </span>
-            <span class="risk-report-text">历史风险报告</span>
-          </div>
-
-          <swipe ref="swipeRef" class="my-swipe" :loop="false" indicator-color="white" @change="handleSwipeChange">
+        <div class="report-content-wrap" v-if="hasReport" v-loading="loading"
+            element-loading-background="rgba(0, 0, 0, 0.1)">
+            <div class="history-risk-report-btn" @click="handleHistoryRiskReportClick">
+                <span class="risk-report-icon">
+                    <i></i>
+                </span>
+                <span class="risk-report-text">历史风险报告</span>
+            </div>
+
+            <swipe ref="swipeRef" class="my-swipe" :loop="false" indicator-color="white" @change="handleSwipeChange">
                 <swipe-item v-for="(item, index) in regionsData" :key="index">
                     <div class="report-content has-report" :style="{ minHeight: `calc(100vh - ${tabBarHeight}px)` }">
                         <!-- <img src="@/assets/img/home/qrcode.png" alt="" class="code-icon" /> -->
@@ -21,7 +22,7 @@
                         <div class="report-header">
                             <!-- <img class="header-book" src="@/assets/img/home/book.png" alt="" /> -->
                             <div class="time-tag">{{ workItems?.[0]?.reportDate }}</div>
-                            <div class="report-title">{{regionsData[currentIndex]?.regionName}}长势报告</div>
+                            <div class="report-title">{{ regionsData[currentIndex]?.regionName }}长势报告</div>
                             <div class="report-info">
                                 <div class="info-item">
                                     <img class="info-icon" src="@/assets/img/home/farm.png" alt="" />
@@ -39,17 +40,13 @@
                             <div class="box-title warning">今日巡园重点</div>
                             <div class="box-text w-100">
                                 <div class="row">
-                                    <div
-                                        v-for="(card, cardI) in todayPatrolFocus"
-                                        :key="cardI"
-                                        class="status-card"
-                                        :class="'today-'+card.color"
-                                        @click="handleTodayPatrolFocusClick(card)"
-                                        >
+                                    <div v-for="(card, cardI) in todayPatrolFocus" :key="cardI" class="status-card"
+                                        :class="'today-' + card.color" @click="handleTodayPatrolFocusClick(card)">
                                         <!-- <badge class="status-badge" dot
                                             :offset="[80, -10]">
                                         </badge> -->
-                                        <div class="status-title" :class="{ 'status-title-small': (card.title || '').length > 6 }">
+                                        <div class="status-title"
+                                            :class="{ 'status-title-small': (card.title || '').length > 6 }">
                                             {{ card.title }}
                                         </div>
                                         <div class="status-sub">
@@ -64,22 +61,23 @@
                             <div class="box-title warning">待执行农事</div>
                             <div class="box-text w-100">
                                 <div class="row">
-                                    <div
-                                        v-for="(card, cardI) in pendingFarmWork"
-                                        :key="cardI"
+                                    <div v-for="(card, cardI) in pendingFarmWork" :key="cardI"
                                         class="status-card pending-card"
                                         :style="{ background: card.purposeColor, color: card.purposeColor === '#FFFFFF' ? '#000' : '#fff' }"
-                                        :class="card.type"
-                                        @click="handlePendingFarmWorkClick(card)"
-                                        >
+                                        :class="card.type" @click="handlePendingFarmWorkClick(card)">
                                         <!-- <badge class="status-badge" dot
                                             :offset="[80, -10]">
                                         </badge> -->
-                                        <div v-if="card.executionLimitDays || card.executionLimitDays === 0" class="tag-name" :style="{ borderColor: card.purposeColor, color: card.purposeColor }">限时 {{ card.executionLimitDays }} 天</div>
-                                        <div class="status-title" :class="{ 'status-title-small': (card.name || '').length > 6 }">
+                                        <div v-if="card.executionLimitDays || card.executionLimitDays === 0"
+                                            class="tag-name"
+                                            :style="{ borderColor: card.purposeColor, color: card.purposeColor }">限时 {{
+                                            card.executionLimitDays }} 天</div>
+                                        <div class="status-title"
+                                            :class="{ 'status-title-small': (card.name || '').length > 6 }">
                                             {{ card.name }}
                                         </div>
-                                        <div class="status-sub pending-sub" :style="{ color: card.purposeColor === '#FFFFFF' ? '#000' : '#fff' }">
+                                        <div class="status-sub pending-sub"
+                                            :style="{ color: card.purposeColor === '#FFFFFF' ? '#000' : '#fff' }">
                                             {{ card.purposeName }}
                                         </div>
                                     </div>
@@ -135,7 +133,8 @@
                 </div>
 
                 <div class="lock-img">
-                    <img @click="handleLockClick" src="@/assets/img/home/lock-blue.png" alt="" class="has-click lock-img-item" />
+                    <img @click="handleLockClick" src="@/assets/img/home/lock-blue.png" alt=""
+                        class="has-click lock-img-item" />
                     <div class="lock-text">
                         专属数字农场,种好卖好
                         <div>点击解锁一键溯源增产</div>
@@ -212,8 +211,12 @@ const currentFarmName = ref('');
 const changeGarden = async ({ id, name }) => {
     if (!id) return;
     currentFarmName.value = name;
-    swipeRef.value && swipeRef.value.swipeTo(0, {immediate:true});
-    currentIndex.value = 0;
+    if (sessionStorage.getItem('activeSwipeIndex')) {
+        currentIndex.value = Number(sessionStorage.getItem('activeSwipeIndex'));
+    } else {
+        currentIndex.value = 0;
+        swipeRef.value && swipeRef.value.swipeTo(0, { immediate: true });
+    }
     paramsPage.value = {
         ...(paramsPage.value || {}),
         subjectId: id,
@@ -299,7 +302,7 @@ const handleTodayPatrolFocusClick = (card) => {
 }
 
 const getTodayPatrolFocus = () => {
-    VE_API.report.todayPatrolFocus({ farmId: paramsPage.value.farmId, regionId:paramsPage.value.regionId }).then(({ data }) => {
+    VE_API.report.todayPatrolFocus({ farmId: paramsPage.value.farmId, regionId: paramsPage.value.regionId }).then(({ data }) => {
         todayPatrolFocus.value = data || [];
     });
 }
@@ -344,7 +347,7 @@ const getRegions = async () => {
         subjectId: paramsPage.value.subjectId,
     }).then(({ data }) => {
         regionsData.value = data || [];
-        if(regionsData.value.length > 0) {
+        if (regionsData.value.length > 0) {
             const guideKey = "GROWTH_REPORT_SWIPE_GUIDE_SHOWN";
             if (!localStorage.getItem(guideKey) && regionsData.value.length > 1) {
                 showSwipeGuide.value = true;
@@ -353,7 +356,7 @@ const getRegions = async () => {
             hasReport.value = true;
 
             // 如果不是点击农情报告已生成弹窗过来的,则显示农情互动弹窗
-            if(!route.query.hideInteraction) {
+            if (!route.query.hideInteraction) {
                 agriExecutePopupRef.value.showPopup(regionsData.value[currentIndex.value].farmId);
             }
 
@@ -379,6 +382,13 @@ const getRegions = async () => {
                     });
                 }
             }
+
+            if (sessionStorage.getItem('activeSwipeIndex')) {
+                nextTick(() => {
+                    swipeRef.value?.swipeTo?.(currentIndex.value, { immediate: true });
+                });
+                sessionStorage.removeItem('activeSwipeIndex');
+            }
         } else {
             hasReport.value = false;
         }
@@ -393,6 +403,7 @@ const clearData = () => {
 };
 
 onDeactivated(() => {
+    sessionStorage.setItem('activeSwipeIndex', currentIndex.value);
     clearData();
 });
 
@@ -594,7 +605,7 @@ onUnmounted(() => {
             width: 100%;
             height: calc(100% - 230px);
             background: linear-gradient(180deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.38) 50%, rgba(255, 255, 255, 0) 100%),
-linear-gradient(0deg, rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0.2));
+                linear-gradient(0deg, rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0.2));
         }
 
         .lock-img {
@@ -610,12 +621,15 @@ linear-gradient(0deg, rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0.2));
             justify-content: center;
             flex-direction: column;
             gap: 16px;
+
             .lock-img-item {
                 width: 57px;
             }
+
             .has-click {
                 pointer-events: auto;
             }
+
             .lock-text {
                 font-size: 14px;
                 color: #000;
@@ -623,6 +637,7 @@ linear-gradient(0deg, rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0.2));
                 line-height: 21px;
                 background: linear-gradient(90deg, rgba(255, 255, 255, 0) 0%, #FFFFFF 50%, rgba(255, 255, 255, 0) 100%);
             }
+
             .lock-btn {
                 width: 140px;
                 height: 40px;
@@ -846,6 +861,7 @@ linear-gradient(0deg, rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0.2));
                     &.today-red {
                         background: #FF6A6A;
                         color: #fff;
+
                         .status-sub {
                             color: #fff;
                         }
@@ -855,6 +871,7 @@ linear-gradient(0deg, rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0.2));
                         color: #fff;
                         position: relative;
                         padding: 9px 0 7px 0;
+
                         .tag-name {
                             position: absolute;
                             top: -8px;