Explorar o código

Merge branch 'master' of http://www.sysuimars.cn:3000/feiniao/feiniao-farm-h5

刘秀芳 hai 1 semana
pai
achega
5408ef66b8

+ 6 - 1
src/api/modules/monitor.js

@@ -77,5 +77,10 @@ module.exports = {
     validatePesticideFertilizerQuotes: {
         url: config.base_dev_url + "z_farm_work_lib/validatePesticideFertilizerQuotes",
         type: "get",
+    },
+    // 批量验证多个农事药肥报价信息是否完整
+    batchValidatePesticideFertilizerQuotes: {
+        url: config.base_dev_url + "z_farm_work_lib/batchValidatePesticideFertilizerQuotes",
+        type: "post",
     }
-}
+};

+ 96 - 18
src/components/pageComponents/FarmWorkPlanTimeline.vue

@@ -21,6 +21,7 @@
                             v-for="(fw, aIdx) in Array.isArray(r.farmWorkArrangeList) ? r.farmWorkArrangeList : []"
                             :key="`arrange-${uniqueTimestamp}-${idx}-${rIdx}-${aIdx}`"
                             class="arrange-card"
+                            :style="shouldShowIncompleteStatus(fw.farmWorkId) ? 'padding-bottom: 18px;' : 'padding-bottom: 10px'"
                             :class="getArrangeStatusClass(fw)"
                             @click="handleRowClick(fw)"
                         >
@@ -35,14 +36,14 @@
                             </div>
                             <div class="card-content">
                                 <span>{{ fw.interactionQuestion || "暂无提示" }}</span>
-                                <span v-if="!disableClick" class="edit-link" @click.stop="handleEdit(fw)"
+                                <span v-if="!disableClick" :class="shouldShowIncompleteStatus(fw.farmWorkId) ? 'link-warning' : 'edit-link'" @click.stop="handleEdit(fw)"
                                     >点击编辑</span
                                 >
                             </div>
-                            <!-- <div class="card-status">
-                                <el-icon color="#FF953D" size="14"><WarningFilled /></el-icon>
+                            <div class="card-status" v-if="shouldShowIncompleteStatus(fw.farmWorkId)">
+                                <el-icon color="#FF953D" size="13"><WarningFilled /></el-icon>
                                 <span>未完善</span>
-                            </div> -->
+                            </div>
                         </div>
                     </div>
                     <div class="phenology-name">{{ r.name }}</div>
@@ -51,13 +52,14 @@
         </div>
     </div>
     <!-- 互动设置弹窗 -->
-    <interact-popup ref="interactPopupRef" @handleSaveSuccess="getFarmWorkPlan"></interact-popup>
+    <interact-popup ref="interactPopupRef" @handleSaveSuccess="updateFarmWorkPlan"></interact-popup>
 </template>
 
 <script setup>
-import { ref, computed, nextTick, watch } from "vue";
+import { ref, nextTick, watch } from "vue";
 import interactPopup from "@/components/popup/interactPopup.vue";
 import { ElMessage } from "element-plus";
+import { WarningFilled } from "@element-plus/icons-vue";
 
 const props = defineProps({
     // 农场 ID,用于请求农事规划数据
@@ -91,7 +93,6 @@ const props = defineProps({
     },
 });
 
-
 const farmWorkType = {
     0: "预警农事",
     1: "标准农事",
@@ -140,6 +141,49 @@ const safeParseDate = (val) => {
     return NaN;
 };
 
+const batchValidateData = ref({});
+// 验证农事卡片药肥报价信息是否完整
+const batchValidatePesticideFertilizerQuotes = (ids) => {
+    if (props.isStandard) {
+        return;
+    }
+    VE_API.monitor
+        .batchValidatePesticideFertilizerQuotes({ ids, schemeId: props.schemeId })
+        .then(({ data,code }) => {
+            if (code === 0) {
+                batchValidateData.value = data || {};
+            }
+        })
+        .catch(() => {});
+};
+
+// 判断是否应该显示"未完善"状态
+// 如果batchValidateData中对应的farmWorkId验证结果为true(已完善),则不显示
+// 如果验证结果为false(未完善)或不存在,则显示
+const shouldShowIncompleteStatus = (farmWorkId) => {
+    if (!farmWorkId || !batchValidateData.value || typeof batchValidateData.value !== 'object') {
+        // 如果没有验证数据,默认不显示
+        return false;
+    }
+
+    // 从对象中直接获取验证结果,支持字符串和数字类型的key
+    const isValid = batchValidateData.value[farmWorkId] !== undefined 
+        ? batchValidateData.value[farmWorkId]
+        : batchValidateData.value[String(farmWorkId)] !== undefined
+        ? batchValidateData.value[String(farmWorkId)]
+        : undefined;
+
+    // 如果找到了验证结果
+    if (isValid !== undefined) {
+        // 如果验证结果为true(已完善),返回false(不显示)
+        // 如果验证结果为false(未完善),返回true(显示)
+        return !isValid;
+    }
+
+    // 如果没有找到验证结果,默认不显示
+    return false;
+};
+
 // 计算物候期需要的实际高度(基于农事数量)
 const getPhenologyRequiredHeight = (item) => {
     // 统计该物候期内的农事数量
@@ -299,10 +343,11 @@ const handleSeasonClick = (seasonValue) => {
 // 农事状态样式映射(0:取消关注,1:关注,2:托管农事,)
 const getArrangeStatusClass = (fw) => {
     const t = fw?.isFollow;
+    const warningStatus = shouldShowIncompleteStatus(fw.farmWorkId);
+    if (warningStatus) return "status-warning";
     if (t == 0) return "normal-style";
     // if (t >= 0 && t <= 4) return "status-normal";
     // if (t === 5) return "status-complete";
-    if (t === 6) return "status-warning";
     return "status-normal";
 };
 
@@ -407,6 +452,31 @@ const getFarmWorkPlan = () => {
                         timelineContainerRef.value.scrollTop = savedScrollTop;
                     }
                 });
+
+                // 收集所有farmWorkId
+                const farmWorkIds = [];
+                phenologyList.value.forEach((phenology) => {
+                    if (Array.isArray(phenology.reproductiveList)) {
+                        phenology.reproductiveList.forEach((reproductive) => {
+                            if (Array.isArray(reproductive.farmWorkArrangeList)) {
+                                reproductive.farmWorkArrangeList.forEach((farmWork) => {
+                                    if (
+                                        farmWork.farmWorkId != null &&
+                                        farmWork.farmWorkId !== undefined &&
+                                        farmWork.farmWorkId !== ""
+                                    ) {
+                                        farmWorkIds.push(farmWork.farmWorkId);
+                                    }
+                                });
+                            }
+                        });
+                    }
+                });
+
+                // 调用验证方法,传入所有ids
+                if (farmWorkIds.length > 0) {
+                    batchValidatePesticideFertilizerQuotes(farmWorkIds);
+                }
             }
         })
         .catch((error) => {
@@ -415,24 +485,28 @@ const getFarmWorkPlan = () => {
         });
 };
 
+const updateFarmWorkPlan = () => {
+    solarTerms.value = [];
+    phenologyList.value = [];
+    getFarmWorkPlan();
+};
+
 watch(
     () => props.farmId || props.containerId,
     (val) => {
         if (val) {
             isInitialLoad.value = true;
-            getFarmWorkPlan();
+            updateFarmWorkPlan();
         }
     },
     { immediate: true }
 );
 watch(
     () => props.schemeId,
-    () => {
-        // 清空旧数据,确保重新渲染
-        solarTerms.value = [];
-        phenologyList.value = [];
-        // 触发数据重新加载
-        getFarmWorkPlan();
+    (val) => {
+        if (val) {
+            updateFarmWorkPlan();
+        }
     }
 );
 </script>
@@ -530,15 +604,19 @@ watch(
                             color: #2199f8;
                             margin-left: 5px;
                         }
+                        .link-warning{
+                            color: #ff953d;
+                            margin-left: 5px;
+                        }
                     }
-                    .card-status{
+                    .card-status {
                         position: absolute;
                         bottom: 0;
                         right: 0;
                         background: rgba(255, 149, 61, 0.1);
                         border-radius: 3px;
-                        color: #FF953D;
-                        padding: 2px 6px;
+                        color: #ff953d;
+                        padding: 0 6px;
                         display: flex;
                         align-items: center;
                         gap: 4px;

+ 1 - 2
src/components/popup/tipPopup.vue

@@ -38,11 +38,10 @@ const props = defineProps({
         type: Boolean,
         default: false,
     },
-    // 类型:'create' 或 'success',决定显示哪个图标
+    // 类型:'create' 或 'success' 或 'warning',决定显示哪个图标
     type: {
         type: String,
         default: "create",
-        // validator: (value) => ["create", "success"].includes(value),
     },
     // 提示文字内容
     text: {

+ 3 - 6
src/views/old_mini/monitor/subPages/plan.vue

@@ -46,7 +46,7 @@
                     @row-click="handleRowClick"
                     :disableClick="!hasPlanPermission || active === tabs[0]?.id"
                     :isStandard="active === tabs[0]?.id"
-                    :schemeId="schemeIdData"
+                    :schemeId="active"
                 />
             </div>
         </div>
@@ -194,12 +194,10 @@ const tabs = ref([]);
 // 控制标签滚动方向:'left' | 'right' | 'auto' | ''
 const scrollType = ref("auto");
 const containerIdData = ref(null);
-const schemeIdData = ref(null);
 const getListMySchemes = (type = "auto") => {
     VE_API.home.listMySchemes({ containerId: specieValue.value }).then(({ data }) => {
         tabs.value = data || [];
         containerIdData.value = data[0]?.containerId;
-        schemeIdData.value = data[0]?.sourceSchemeId;
         if (type === "right") {
             active.value = data[data.length - 1].id;
         } else if (type === "left") {
@@ -217,7 +215,6 @@ const currentTab = ref(null);
 const handleTabChange = (id, item) => {
     active.value = id;
     currentTab.value = item;
-    schemeIdData.value = item.sourceSchemeId;
     getFarmWorkPlanForPhenology();
 };
 
@@ -243,7 +240,7 @@ const getFarmWorkPlanForPhenology = async () => {
         const { data, code } = await VE_API.monitor.farmWorkPlan({
             containerId: specieValue.value,
             farmId: route.query.farmId,
-            schemeId: schemeIdData.value,
+            schemeId: active.value,
         });
         if (code === 0 && data?.phenologyList?.[0]?.containerSpaceTimeId) {
             containerSpaceTimeId.value = data.phenologyList[0].containerSpaceTimeId;
@@ -433,7 +430,7 @@ const handleRowClick = (item) => {
                 height: calc(100vh - 90px - 85px - 38px);
             }
             &.no-default-plan-wrap {
-                height: calc(100vh - 90px - 85px - 100px);
+                height: calc(100vh - 90px - 85px - 66px);
             }
             // 没有权限时,底部按钮不显示,高度增加 73px
             &.timeline-container-no-permission-wrap {