Ver Fonte

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

lxf há 4 dias atrás
pai
commit
8717d6aafe

+ 1 - 0
src/components/popup/interactPopup.vue

@@ -48,6 +48,7 @@
                         v-model="formData.interactionTime"
                         size="large"
                         style="width: 100%"
+                        disabled
                         type="date"
                         placeholder="请选择日期"
                         :editable="false"

+ 1 - 1
src/views/old_mini/modify_work/modify.vue

@@ -122,7 +122,7 @@
                             <div class="form-input-wrapper">
                                 <el-date-picker
                                     v-model="interactFormData.interactionTime"
-                                   
+                                    disabled
                                     style="width: 100%"
                                     type="date"
                                     placeholder="请选择日期"

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

@@ -124,11 +124,17 @@
                         size="large"
                         value-format="YYYY-MM-DD"
                         v-model="item.startDate"
+                        :clearable="false"
                         type="date"
                         placeholder="选择日期"
+                        @change="(date) => handleStartDateChange(date, index)"
                     />
                 </div>
             </div>
+            <div class="phenology-footer-tip">
+                <span>注:</span>
+                <span class="text">请从上往下按照时间顺序填写日期</span>
+            </div>
         </div>
         <div class="phenology-footer" @click="handleConfirmPhenologySetting">确认设置</div>
     </Popup>
@@ -144,7 +150,7 @@
 </template>
 
 <script setup>
-import { ref, onMounted, computed} from "vue";
+import { ref, onMounted, computed, watch } from "vue";
 import { Popup, Highlight } from "vant";
 import customHeader from "@/components/customHeader.vue";
 import tabList from "@/components/pageComponents/TabList.vue";
@@ -286,11 +292,20 @@ const getPhenologyList = async () => {
     };
     const res = await VE_API.monitor.listPhenology(params);
     if (res.code === 0) {
-        mergedReproductiveList.value = res.data || [];
+        // 将intervalDaysArr合并到mergedReproductiveList中
+        if (intervalDaysArr.value.length > 0 && res.data.length > 0) {
+            mergedReproductiveList.value = res.data.map((item, index) => {
+                return {
+                    ...item,
+                    intervalDays: intervalDaysArr.value[index],
+                };
+            });
+        }
     }
 };
 
 const farmWorkIds = ref([]);
+const intervalDaysArr = ref([]);
 // 获取农事规划数据以获取 containerSpaceTimeId
 const getFarmWorkPlanForPhenology = async () => {
     try {
@@ -305,7 +320,9 @@ const getFarmWorkPlanForPhenology = async () => {
 
             // 收集所有farmWorkId
             farmWorkIds.value = [];
+            intervalDaysArr.value = [];
             data.phenologyList.forEach((phenology) => {
+                intervalDaysArr.value.push(phenology.intervalDays);
                 if (Array.isArray(phenology.reproductiveList)) {
                     phenology.reproductiveList.forEach((reproductive) => {
                         if (Array.isArray(reproductive.farmWorkArrangeList)) {
@@ -344,6 +361,43 @@ const handlePhenologySetting = () => {
 };
 
 /**
+ * 处理物候期开始时间变化
+ * 当修改某个物候期的开始时间时,自动更新后续所有物候期的开始时间
+ */
+const handleStartDateChange = (date, currentIndex) => {
+    if (!date || !mergedReproductiveList.value || mergedReproductiveList.value.length === 0) {
+        return;
+    }
+    
+    // 从当前修改的物候期开始,更新后续所有物候期的开始时间
+    for (let i = currentIndex; i < mergedReproductiveList.value.length - 1; i++) {
+        const currentItem = mergedReproductiveList.value[i];
+        const nextItem = mergedReproductiveList.value[i + 1];
+        
+        // 获取当前物候期的间隔天数
+        const intervalDays = currentItem.intervalDays || 0;
+        
+        if (intervalDays > 0 && currentItem.startDate) {
+            // 将日期字符串转换为时间戳(毫秒)
+            const currentStartDateTimestamp = new Date(currentItem.startDate).getTime();
+            
+            // 在时间戳基础上加上间隔天数(转换为毫秒:天数 * 24小时 * 60分钟 * 60秒 * 1000毫秒)
+            const nextStartDateTimestamp = currentStartDateTimestamp + (intervalDays * 24 * 60 * 60 * 1000);
+            
+            // 将时间戳转换回日期对象,然后格式化为 YYYY-MM-DD 格式
+            const nextStartDate = new Date(nextStartDateTimestamp);
+            const year = nextStartDate.getFullYear();
+            const month = String(nextStartDate.getMonth() + 1).padStart(2, '0');
+            const day = String(nextStartDate.getDate()).padStart(2, '0');
+            const nextStartDateStr = `${year}-${month}-${day}`;
+            
+            // 更新下一个物候期的开始时间
+            nextItem.startDate = nextStartDateStr;
+        }
+    }
+};
+
+/**
  * 确认物候期设置
  */
 const handleConfirmPhenologySetting = async () => {
@@ -689,11 +743,18 @@ const handleRowClick = (item) => {
             margin-top: 10px;
         }
     }
+    .phenology-footer-tip {
+        margin-top: 20px;
+        text-align: center;
+        .text{
+            color: rgba(0, 0, 0, 0.4);
+        }
+    }
     .phenology-footer {
         width: 100%;
         text-align: center;
         font-size: 16px;
-        margin-top: 20px;
+        margin-top: 10px;
         color: #fff;
         background: #2199f8;
         border-radius: 25px;