Просмотр исходного кода

feat:对接提交方案接口

wangsisi 1 неделя назад
Родитель
Сommit
3433c294c0

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

@@ -82,5 +82,10 @@ module.exports = {
     batchValidatePesticideFertilizerQuotes: {
         url: config.base_dev_url + "z_farm_work_lib/batchValidatePesticideFertilizerQuotes",
         type: "post",
-    }
+    },
+    //将方案设置为可用
+    enableScheme: {
+        url: config.base_dev_url + "container_farm_work_scheme/enableScheme",
+        type: "get",
+    },
 };

+ 2 - 6
src/components/pageComponents/FarmWorkPlanTimeline.vue

@@ -326,8 +326,8 @@ const handleSeasonClick = (seasonValue) => {
 const getArrangeStatusClass = (fw) => {
     const t = fw?.isFollow;
     const warningStatus = shouldShowIncompleteStatus(fw.farmWorkId);
-    if (warningStatus) return "status-warning";
     if (t == 0) return "normal-style";
+    if (warningStatus) return "status-warning";
     // if (t >= 0 && t <= 4) return "status-normal";
     // if (t === 5) return "status-complete";
     return "status-normal";
@@ -453,11 +453,7 @@ const getFarmWorkPlan = () => {
                         phenology.reproductiveList.forEach((reproductive) => {
                             if (Array.isArray(reproductive.farmWorkArrangeList)) {
                                 reproductive.farmWorkArrangeList.forEach((farmWork) => {
-                                    if (
-                                        farmWork.farmWorkId != null &&
-                                        farmWork.farmWorkId !== undefined &&
-                                        farmWork.farmWorkId !== ""
-                                    ) {
+                                    if (farmWork.farmWorkId && farmWork.isFollow !== 0) {
                                         farmWorkIds.push(farmWork.farmWorkId);
                                     }
                                 });

+ 3 - 1
src/views/old_mini/home/components/AgriculturalDynamics.vue

@@ -29,7 +29,7 @@
                     <!-- 头部区域 -->
                     <div class="header-section">
                         <div class="header-left">
-                            <div class="farm-name">{{ item.farmName }}</div>
+                            <div class="farm-name van-ellipsis">{{ item.farmName }}</div>
                             <div class="tag-group">
                                 <div class="tag tag-blue">{{ item.typeName }}</div>
                                 <div class="tag" :class="{'tag-orange': item.userType === 2}">{{ item.userType === 1 ? '普通客户' : '托管客户' }}</div>
@@ -266,10 +266,12 @@ const getFutureFarmWorkWarning = async (item) => {
                     display: flex;
                     align-items: center;
                     gap: 8px;
+                    width: calc(100% - 80px);
                     .farm-name {
                         font-size: 16px;
                         font-weight: 500;
                         color: #1d2129;
+                        max-width: calc(100% - 130px);
                     }
 
                     .tag-group {

+ 71 - 17
src/views/old_mini/monitor/subPages/plan.vue

@@ -36,7 +36,8 @@
                 :class="{
                     'timeline-container-plant-wrap': pageType == 'plant',
                     'timeline-container-no-permission-wrap': !hasPlanPermission,
-                    'no-default-plan-wrap': active !== tabs[0]?.id && pageType == 'plant' && currentTab?.enabled == 0,
+                    'no-default-plan-wrap':
+                        active !== tabs[0]?.id && pageType == 'plant' && tabs[currentTabIndex]?.enabled == 0,
                 }"
             >
                 <farm-work-plan-timeline
@@ -50,9 +51,16 @@
                 />
             </div>
         </div>
-        <div class="custom-bottom-fixed-btns" :class="{ center: (active === tabs[0]?.id && pageType == 'plant') }" v-has-permission="'农事规划'">
+        <div
+            class="custom-bottom-fixed-btns"
+            :class="{ center: active === tabs[0]?.id && pageType == 'plant' }"
+            v-has-permission="'农事规划'"
+        >
             <div class="bottom-btn-group-wrap">
-                <div class="bottom-btn-group" :class="{ 'justify-center': active === tabs[0]?.id && pageType == 'plant' }">
+                <div
+                    class="bottom-btn-group"
+                    :class="{ 'justify-center': active === tabs[0]?.id && pageType == 'plant' }"
+                >
                     <div
                         class="bottom-btn secondary-btn"
                         @click="handlePhenologySetting"
@@ -66,7 +74,7 @@
                 </div>
                 <div class="bottom-btn primary-btn" @click="addNewTask" v-show="active !== tabs[0]?.id">新增农事</div>
             </div>
-            <template v-if="active !== tabs[0]?.id && pageType == 'plant' && currentTab?.enabled == 0">
+            <template v-if="active !== tabs[0]?.id && pageType == 'plant' && tabs[currentTabIndex]?.enabled == 0">
                 <div class="bottom-btn-divider"></div>
                 <div class="bottom-btn primary-btn submit-btn" @click="handleSubmitPlan">提交方案</div>
             </template>
@@ -182,9 +190,9 @@ const getSpecieList = () => {
     VE_API.farm.fetchSpecieList({ agriculturalId: userInfo?.agriculturalId }).then(({ data }) => {
         if (data && data.length) {
             options.value = data || [];
-            if(sessionStorage.getItem('specieValue')) {
-                specieValue.value = sessionStorage.getItem('specieValue');
-                sessionStorage.removeItem('specieValue');
+            if (sessionStorage.getItem("specieValue")) {
+                specieValue.value = sessionStorage.getItem("specieValue");
+                sessionStorage.removeItem("specieValue");
             } else {
                 specieValue.value = data[0]?.defaultContainerId;
             }
@@ -203,9 +211,9 @@ const getListMySchemes = (type = "auto") => {
     VE_API.home.listMySchemes({ containerId: specieValue.value }).then(({ data }) => {
         tabs.value = data || [];
         containerIdData.value = tabs.value[0]?.containerId;
-        if(sessionStorage.getItem('active')) {
-            active.value = sessionStorage.getItem('active');
-            sessionStorage.removeItem('active');
+        if (sessionStorage.getItem("active")) {
+            active.value = sessionStorage.getItem("active");
+            sessionStorage.removeItem("active");
         } else {
             if (type === "right") {
                 active.value = data[data.length - 1].id;
@@ -222,9 +230,11 @@ const getListMySchemes = (type = "auto") => {
 };
 
 const currentTab = ref(null);
-const handleTabChange = (id, item) => {
+const currentTabIndex = ref(0);
+const handleTabChange = (id, item, index) => {
     active.value = id;
     currentTab.value = item;
+    currentTabIndex.value = index;
     getFarmWorkPlanForPhenology();
 };
 
@@ -244,6 +254,7 @@ const getPhenologyList = async () => {
     }
 };
 
+const farmWorkIds = ref([]);
 // 获取农事规划数据以获取 containerSpaceTimeId
 const getFarmWorkPlanForPhenology = async () => {
     try {
@@ -255,6 +266,23 @@ const getFarmWorkPlanForPhenology = async () => {
         if (code === 0 && data?.phenologyList?.[0]?.containerSpaceTimeId) {
             containerSpaceTimeId.value = data.phenologyList[0].containerSpaceTimeId;
             schemeId.value = data.phenologyList[0].reproductiveList[0].farmWorkArrangeList[0].schemeId;
+
+            // 收集所有farmWorkId
+            farmWorkIds.value = [];
+            data.phenologyList.forEach((phenology) => {
+                if (Array.isArray(phenology.reproductiveList)) {
+                    phenology.reproductiveList.forEach((reproductive) => {
+                        if (Array.isArray(reproductive.farmWorkArrangeList)) {
+                            reproductive.farmWorkArrangeList.forEach((farmWork) => {
+                                if (farmWork.farmWorkId && farmWork.isFollow !== 0) {
+                                    farmWorkIds.value.push(farmWork.farmWorkId);
+                                }
+                            });
+                        }
+                    });
+                }
+            });
+
             await getPhenologyList(containerSpaceTimeId.value);
         }
     } catch (error) {
@@ -360,14 +388,38 @@ const handleConfirmCopyPlan = () => {
     }
 };
 
-const handleSubmitPlan = () => {
-    // showTipPopup.value = true;
-    console.log('ti')
+// 提交方案
+const handleSubmitPlan = async () => {
+    // 调用验证方法,传入所有ids
+    if (farmWorkIds.value.length > 0) {
+        const { data, code } = await VE_API.monitor.batchValidatePesticideFertilizerQuotes({
+            ids: farmWorkIds.value,
+            schemeId: active.value,
+        });
+        if (code === 0) {
+            // 判断data对象中所有的值是否都为true
+            const allTrue = Object.values(data).every((value) => value === true);
+            if (allTrue) {
+                VE_API.monitor
+                    .enableScheme({
+                        schemeId: active.value,
+                    })
+                    .then(({ code }) => {
+                        if (code === 0) {
+                            ElMessage.success("提交成功");
+                            getListMySchemes("auto");
+                        }
+                    });
+            } else {
+                showTipPopup.value = true;
+            }
+        }
+    }
 };
 
 const savePlanPageInfo = () => {
-    sessionStorage.setItem('specieValue', specieValue.value);
-    sessionStorage.setItem('active', active.value);
+    sessionStorage.setItem("specieValue", specieValue.value);
+    sessionStorage.setItem("active", active.value);
 };
 
 // 新增农事
@@ -399,11 +451,13 @@ const handleRowClick = (item) => {
         path: "/modify",
         query: {
             id: item.id,
-            noPrice: pageType.value === 'plant' ? true : false,
+            noPrice: pageType.value === "plant" ? true : false,
             farmId: route.query.farmId,
             farmWorkId: item.farmWorkId,
             containerSpaceTimeId: item.containerSpaceTimeId,
             isDefault: active.value === tabs.value[0]?.id,
+            farmWorkIds: farmWorkIds.value,
+            enabled: tabs.value[currentTabIndex.value]?.enabled,
         },
     });
 };

+ 1 - 0
src/views/old_mini/plan/index.vue

@@ -17,6 +17,7 @@
                 <farm-work-plan-timeline
                     pageType="plant"
                     :containerId="containerId"
+                    :schemeId="active"
                     :disableClick="true"
                 />
             </div>