Explorar o código

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

wangsisi hai 1 semana
pai
achega
165b4d12a9

+ 62 - 15
src/views/old_mini/modify_work/modify.vue

@@ -623,14 +623,18 @@ const noPrice = ref(false);
 const isDefault = ref(false);
 // 是否在完善信息弹窗中
 const isDoingComplete = ref(false);
+const farmWorkIds = ref([]);
 
 const showCompletePopup = ref(false);
 onActivated(() => {
     isDefault.value = route.query.isDefault == 'true' ? true : false;
-    isEdit.value = route.query.isEdit ? true : false;
-    onlyPrice.value = route.query.onlyPrice ? true : false;
+    isEdit.value = route.query.isEdit == 'true' ? true : false;
+    onlyPrice.value = route.query.onlyPrice == 'true' ? true : false;
     noPrice.value = route.query.noPrice == 'true' ? true : false;
-    isDoingComplete.value = route.query.isDoingComplete == 'true' ? true : false;
+    // enabled为0时,方案不可用,需要完善
+    isDoingComplete.value = route.query.enabled == 0 ? true : false;
+    // 方案列表中的ids数组
+    farmWorkIds.value = route.query.farmWorkIds ? JSON.parse(route.query.farmWorkIds) : [];
     if (route.query.farmWorkId) {
         getDetail();
     }
@@ -779,18 +783,61 @@ const handleViewDetail = () => {
 
 const handleCompleteNext = () => {
     showCompletePopup.value = false;
-    router.replace({
-        path: "/modify",
-        query: {
-            farmWorkId: route.query.farmWorkId,
-            farmId: route.query.farmId,
-            id: route.query.id,
-            isEdit: true,
-            onlyPrice: false,
-            noPrice: false,
-            isDefault: false,
-        },
-    });
+    const farmWorkIds = sessionStorage.getItem("farmWorkIds");
+    const arrangeIds = sessionStorage.getItem("arrangeIds");
+    if (farmWorkIds && arrangeIds) {
+        const farmWorkIdsArray = JSON.parse(farmWorkIds);
+        const arrangeIdsArray = JSON.parse(arrangeIds);
+        // 找到当前 farmWorkId 在数组中的索引
+        const currentFarmWorkId = route.query.farmWorkId;
+        const currentIndex = farmWorkIdsArray.findIndex(id => id == currentFarmWorkId);
+        
+        if (currentIndex !== -1) {
+            // 从数组中删除当前项
+            farmWorkIdsArray.splice(currentIndex, 1);
+            arrangeIdsArray.splice(currentIndex, 1);
+            
+            // 更新 sessionStorage
+            sessionStorage.setItem("farmWorkIds", JSON.stringify(farmWorkIdsArray));
+            sessionStorage.setItem("arrangeIds", JSON.stringify(arrangeIdsArray));
+            
+            // 获取下一个(如果当前索引还在数组范围内,则取当前索引位置的值,否则取第一个)
+            if (farmWorkIdsArray.length > 0 && arrangeIdsArray.length > 0) {
+                const nextIndex = currentIndex < farmWorkIdsArray.length ? currentIndex : 0;
+                const nextFarmWorkId = farmWorkIdsArray[nextIndex];
+                const nextArrangeId = arrangeIdsArray[nextIndex];
+                
+                router.replace({
+                    path: "/modify",
+                    query: {
+                        id: nextArrangeId,
+                        farmWorkId: nextFarmWorkId,
+                        farmId: route.query.farmId,
+                        containerSpaceTimeId: route.query.containerSpaceTimeId,
+                        schemeId: route.query.schemeId,
+                        enabled: 0,
+                        isEdit: true,
+                        onlyPrice: false,
+                        noPrice: true,
+                        isDefault: false,
+                    },
+                });
+                router.reload();
+            }
+        }
+    }
+    // router.replace({
+    //     path: "/modify",
+    //     query: {
+    //         farmWorkId: route.query.farmWorkId,
+    //         farmId: route.query.farmId,
+    //         id: route.query.id,
+    //         isEdit: true,
+    //         onlyPrice: false,
+    //         noPrice: false,
+    //         isDefault: false,
+    //     },
+    // });
 };
 const resetForm = (formEl) => {
     if (!formEl) return;

+ 8 - 2
src/views/old_mini/monitor/subPages/plan.vue

@@ -268,6 +268,7 @@ const getPhenologyList = async () => {
 };
 
 const farmWorkIds = ref([]);
+const arrangeIds = ref([]);
 // 获取农事规划数据以获取 containerSpaceTimeId
 const getFarmWorkPlanForPhenology = async () => {
     try {
@@ -282,6 +283,7 @@ const getFarmWorkPlanForPhenology = async () => {
 
             // 收集所有farmWorkId
             farmWorkIds.value = [];
+            arrangeIds.value = [];
             data.phenologyList.forEach((phenology) => {
                 if (Array.isArray(phenology.reproductiveList)) {
                     phenology.reproductiveList.forEach((reproductive) => {
@@ -289,6 +291,7 @@ const getFarmWorkPlanForPhenology = async () => {
                             reproductive.farmWorkArrangeList.forEach((farmWork) => {
                                 if (farmWork.farmWorkId && farmWork.isFollow !== 0) {
                                     farmWorkIds.value.push(farmWork.farmWorkId);
+                                    arrangeIds.value.push(farmWork.id);
                                 }
                             });
                         }
@@ -433,6 +436,8 @@ const handleSubmitPlan = async () => {
 const savePlanPageInfo = () => {
     sessionStorage.setItem("specieValue", specieValue.value);
     sessionStorage.setItem("active", active.value);
+    sessionStorage.setItem("farmWorkIds", JSON.stringify(farmWorkIds.value));
+    sessionStorage.setItem("arrangeIds", JSON.stringify(arrangeIds.value));
     sessionStorage.setItem("currentTabIndex", currentTabIndex.value);
 };
 
@@ -461,6 +466,7 @@ const curFarmObj = ref({});
 const handleRowClick = (item) => {
     curFarmObj.value = item;
     savePlanPageInfo();
+    const enabled = tabs.value[currentTabIndex.value]?.enabled;
     router.push({
         path: "/modify",
         query: {
@@ -470,8 +476,8 @@ const handleRowClick = (item) => {
             farmWorkId: item.farmWorkId,
             containerSpaceTimeId: item.containerSpaceTimeId,
             isDefault: active.value === tabs.value[0]?.id,
-            farmWorkIds: farmWorkIds.value,
-            enabled: tabs.value[currentTabIndex.value]?.enabled,
+            enabled: enabled,
+            isEdit: enabled ? false : true,
         },
     });
 };