ソースを参照

fix: 增加生育期

lxf 5 日 前
コミット
9fd6edfe7e

+ 5 - 0
src/api/modules/farm.js

@@ -71,4 +71,9 @@ module.exports = {
         url: config.base_dev_url + "agricultural_store_pesticide_fertilizer/updateBatchByScheme",
         type: "post",
     },
+    // 生育期
+    listByPhenologyId: {
+        url: config.base_dev_url + "container_reproductive/listByPhenologyId",
+        type: "get",
+    },
 }

+ 4 - 4
src/components/popup/activeUploadPopup.vue

@@ -333,11 +333,11 @@ defineExpose({
 function handleClosed() {
     eventBus.emit("upload:reset");
     // 清除所有数据
-    // images.value = [];
+    images.value = [];
     // uploadDate.value = "";
-    // executorId.value = null;
-    // needReview.value = false;
-    // reviewDay.value = null;
+    executorId.value = null;
+    needReview.value = null;
+    reviewDay.value = null;
     // currentPhenologyId.value = null;
     // gardenId.value = null;
     // problemTitle.value = "请选择问题";

+ 52 - 12
src/components/popup/interactPopup.vue

@@ -9,15 +9,33 @@
                     <span class="required">*</span>
                     请选择互动阶段
                 </div>
-                <div class="form-input-wrapper">
-                    <el-select v-model="formData.phenologyId" size="large" placeholder="请选择物候期" :editable="false">
-                        <el-option
-                            v-for="item in phenologyList"
-                            :key="item.id"
-                            :label="item.name"
-                            :value="item.id"
-                        ></el-option>
-                    </el-select>
+                <div class="form-input-wrapper two-select">
+                    <div class="select-item">
+                        <el-select
+                            v-model="formData.phenologyId"
+                            size="large"
+                            placeholder="请选择物候期"
+                            @change="handlePhenologyChange"
+                            :editable="false"
+                        >
+                            <el-option
+                                v-for="item in phenologyList"
+                                :key="item.id"
+                                :label="item.name"
+                                :value="item.id"
+                            ></el-option>
+                        </el-select>
+                    </div>
+                    <div class="select-item">
+                        <el-select v-model="formData.reproductiveId" size="large" placeholder="请选择" :editable="false">
+                            <el-option
+                                v-for="item in reproductiveList"
+                                :key="item.id"
+                                :label="item.name"
+                                :value="item.id"
+                            ></el-option>
+                        </el-select>
+                    </div>
                 </div>
             </div>
             <div class="form-item">
@@ -76,10 +94,19 @@ const isSaving = ref(false);
 
 const formData = ref({
     phenologyId: "",
+    reproductiveId: "",
     interactionTime: "",
     interactionQuestion: "",
 });
 
+const reproductiveList = ref([]);
+const handlePhenologyChange = async (val) => {
+    formData.value.reproductiveId = "";
+    const { data } = await VE_API.farm.listByPhenologyId({ phenologyId: val });
+    if (!data || !Array.isArray(data)) return;
+    reproductiveList.value = data;
+};
+
 // 计算属性
 const saveButtonText = computed(() => (isSaving.value ? "保存中..." : "保存修改"));
 
@@ -87,6 +114,7 @@ const saveButtonText = computed(() => (isSaving.value ? "保存中..." : "保存
 const resetInteractData = () => {
     formData.value = {
         phenologyId: "",
+        reproductiveId: "",
         interactionTime: "",
         interactionQuestion: "",
     };
@@ -95,11 +123,15 @@ const resetInteractData = () => {
 // 验证函数
 const validateInteractForm = () => {
     if (!formData.value.phenologyId) {
-        ElMessage.warning("请选择互动时间");
+        ElMessage.warning("请选择互动阶段");
+        return false;
+    }
+    if (!formData.value.reproductiveId) {
+        ElMessage.warning("请选择互动阶段");
         return false;
     }
     if (!formData.value.interactionTime) {
-        ElMessage.warning("请选择强制触发互动时间");
+        ElMessage.warning("请选择互动时间");
         return false;
     }
     if (!formData.value.interactionQuestion?.trim()) {
@@ -124,8 +156,10 @@ const getPhenologyList = async (containerSpaceTimeId) => {
 const getFarmWorkArrangeDetail = async (id) => {
     const { data, code } = await VE_API.farm.getFarmWorkArrangeDetail({ id });
     if(code === 0) {
+        await handlePhenologyChange(data.phenologyId);
         formData.value = {
             phenologyId: data.phenologyId,
+            reproductiveId: data.reproductiveId,
             interactionTime: data.interactionTime,
             interactionQuestion: data.interactionQuestion || "",
         };
@@ -261,7 +295,13 @@ defineExpose({
 
             .form-input-wrapper {
                 position: relative;
-
+                &.two-select {
+                    display: flex;
+                    gap: 10px;
+                    .select-item {
+                        flex: 1;
+                    }
+                }
                 ::v-deep {
                     .el-input__inner {
                         caret-color: transparent;

+ 47 - 14
src/views/old_mini/modify_work/addWork.vue

@@ -54,20 +54,32 @@
                     <div class="interact-form">
                         <div class="interact-form-item" data-interact-field="phenologyId">
                             <div class="form-label">互动阶段</div>
-                            <div class="form-input-wrapper">
-                                <el-select
-                                    style="width: 100%"
-                                    v-model="interactFormData.phenologyId"
-                                    placeholder="请选择物候期"
-                                    :editable="false"
-                                >
-                                    <el-option
-                                        v-for="item in phenologyList"
-                                        :key="item.id"
-                                        :label="item.name"
-                                        :value="item.id"
-                                    ></el-option>
-                                </el-select>
+                            <div class="form-input-wrapper two-select">
+                                <div class="select-item">
+                                    <el-select
+                                        style="width: 100%"
+                                        v-model="interactFormData.phenologyId"
+                                        placeholder="请选择物候期"
+                                        @change="handlePhenologyChange"
+                                        :editable="false">
+                                        <el-option
+                                            v-for="item in phenologyList"
+                                            :key="item.id"
+                                            :label="item.name"
+                                            :value="item.id"
+                                        ></el-option>
+                                    </el-select>
+                                </div>
+                                <div class="select-item">
+                                    <el-select style="width: 100%" v-model="interactFormData.reproductiveId" placeholder="请选择物候期" :editable="false">
+                                        <el-option
+                                            v-for="item in reproductiveList"
+                                            :key="item.id"
+                                            :label="item.name"
+                                            :value="item.id"
+                                        ></el-option>
+                                    </el-select>
+                                </div>
                             </div>
                         </div>
                         <div class="interact-form-item" data-interact-field="interactionTime">
@@ -335,10 +347,18 @@ const tagName = ref("");
 // 互动表单数据
 const interactFormData = ref({
     phenologyId: "",
+    reproductiveId: "",
     interactionTime: "",
     interactionQuestion: "",
 });
 const phenologyList = ref([]);
+const reproductiveList = ref([]);
+const handlePhenologyChange = async (val) => {
+    interactFormData.value.reproductiveId = "";
+    const { data } = await VE_API.farm.listByPhenologyId({ phenologyId: val });
+    if (!data || !Array.isArray(data)) return;
+    reproductiveList.value = data;
+};
 
 onMounted(() => {
     getPhenologyList()
@@ -738,6 +758,7 @@ const getFarmWorkArrangeDetail = async (id) => {
         tagName.value = data.isFollow;
         interactFormData.value = {
             phenologyId: data.phenologyId || "",
+            reproductiveId: data.reproductiveId || "",
             interactionTime: data.interactionTime || "",
             interactionQuestion: data.interactionQuestion || "",
         };
@@ -776,6 +797,10 @@ const validateInteractForm = () => {
         ElMessage.warning("请选择互动阶段");
         return false;
     }
+    if (!interactFormData.value.reproductiveId) {
+        ElMessage.warning("请选择互动阶段");
+        return false;
+    }
     if (!interactFormData.value.interactionTime) {
         ElMessage.warning("请选择互动时间");
         return false;
@@ -825,6 +850,7 @@ const handleDeleteInteract = () => {
                 // 清空表单数据
                 interactFormData.value = {
                     phenologyId: "",
+                    reproductiveId: "",
                     interactionTime: "",
                     interactionQuestion: "",
                 };
@@ -1392,6 +1418,13 @@ const handleDeleteInteract = () => {
             .form-input-wrapper {
                 position: relative;
                 width: calc(100% - 70px);
+                &.two-select {
+                    display: flex;
+                    gap: 10px;
+                    .select-item {
+                        flex: 1;
+                    }
+                }
                 ::v-deep {
                     .el-input__inner {
                         caret-color: transparent;

+ 49 - 10
src/views/old_mini/modify_work/modify.vue

@@ -87,15 +87,32 @@
                             <div class="form-label">
                                 互动阶段
                             </div>
-                            <div class="form-input-wrapper">
-                                <el-select style="width: 100%" v-model="interactFormData.phenologyId" placeholder="请选择物候期" :editable="false">
-                                    <el-option
-                                        v-for="item in phenologyList"
-                                        :key="item.id"
-                                        :label="item.name"
-                                        :value="item.id"
-                                    ></el-option>
-                                </el-select>
+                            <div class="form-input-wrapper two-select">
+                                <div class="select-item">
+                                    <el-select
+                                        style="width: 100%"
+                                        v-model="interactFormData.phenologyId"
+                                        placeholder="请选择物候期"
+                                        @change="handlePhenologyChange"
+                                        :editable="false">
+                                        <el-option
+                                            v-for="item in phenologyList"
+                                            :key="item.id"
+                                            :label="item.name"
+                                            :value="item.id"
+                                        ></el-option>
+                                    </el-select>
+                                </div>
+                                <div class="select-item">
+                                    <el-select style="width: 100%" v-model="interactFormData.reproductiveId" placeholder="请选择物候期" :editable="false">
+                                        <el-option
+                                            v-for="item in reproductiveList"
+                                            :key="item.id"
+                                            :label="item.name"
+                                            :value="item.id"
+                                        ></el-option>
+                                    </el-select>
+                                </div>
                             </div>
                         </div>
                         <div class="interact-form-item" data-interact-field="interactionTime">
@@ -607,11 +624,12 @@ const tagName = ref("");
 // 互动表单数据
 const interactFormData = ref({
     phenologyId: "",
+    reproductiveId: "",
     interactionTime: "",
     interactionQuestion: "",
 });
 const phenologyList = ref([]);
-
+const reproductiveList = ref([]);
 // 是否编辑
 const isEdit = ref(false);
 // 是否只显示价格,不需要农情互动
@@ -677,6 +695,13 @@ const showPriceSheetPopup = () => {
     priceSheetPopupRef.value.handleShowPopup(detailData.value);
 };
 
+const handlePhenologyChange = async (val) => {
+    interactFormData.value.reproductiveId = "";
+    const { data } = await VE_API.farm.listByPhenologyId({ phenologyId: val });
+    if (!data || !Array.isArray(data)) return;
+    reproductiveList.value = data;
+};
+
 const statusMap = ref({
     0: "",
     1: "特别关注",
@@ -706,6 +731,7 @@ const getDetail = async () => {
             // 重置互动表单数据
             interactFormData.value = {
                 phenologyId: "",
+                reproductiveId: "",
                 interactionTime: "",
                 interactionQuestion: "",
             };
@@ -1300,8 +1326,10 @@ const getFarmWorkArrangeDetail = async (id) => {
     const { data, code } = await VE_API.farm.getFarmWorkArrangeDetail({ id });
     if(code === 0) {
         tagName.value = data.isFollow === 0 ? null : data.isFollow;
+        await handlePhenologyChange(data.phenologyId);
         interactFormData.value = {
             phenologyId: data.phenologyId || "",
+            reproductiveId: data.reproductiveId || "",
             interactionTime: data.interactionTime || "",
             interactionQuestion: data.interactionQuestion || "",
         };
@@ -1331,6 +1359,10 @@ const validateInteractForm = () => {
         ElMessage.warning("请选择互动阶段");
         return false;
     }
+    if (!interactFormData.value.reproductiveId) {
+        ElMessage.warning("请选择互动阶段");
+        return false;
+    }
     if (!interactFormData.value.interactionTime) {
         ElMessage.warning("请选择互动时间");
         return false;
@@ -1948,6 +1980,13 @@ const handleDeleteInteract = () => {
             .form-input-wrapper {
                 position: relative;
                 width: calc(100% - 70px);
+                &.two-select {
+                    display: flex;
+                    gap: 10px;
+                    .select-item {
+                        flex: 1;
+                    }
+                }
                 ::v-deep {
                     .el-input__inner {
                         caret-color: transparent;

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

@@ -52,7 +52,7 @@
                     @row-click="handleRowClick"
                     :disableClick="!hasPlanPermission || active === tabs[0]?.id"
                     :isStandard="active === tabs[0]?.id"
-                    :schemeId="active"
+                    :schemeId="route.query.schemeId || active"
                 />
             </div>
         </div>
@@ -468,7 +468,7 @@ const addNewTask = () => {
         path: "/add_work",
         query: {
             containerSpaceTimeId: containerSpaceTimeId.value,
-            schemeId: schemeId.value,
+            schemeId: route.query.schemeId || schemeId.value,
         },
     });
 };

+ 10 - 25
src/views/old_mini/task_condition/components/task.vue

@@ -173,13 +173,15 @@ const getStartFlowStatus = (index) => {
 // 获取单个状态的任务数量
 function getTaskCount(flowStatus, index) {
     const location = store.state.home.miniUserLocationPoint;
-    const needReview = activeIndex.value === 2 ? 1 : null;
-    const includePrescription = activeIndex.value === 0 ? false : true;
+    // 根据传入的 index 参数来设置 needReview 和 includePrescription,而不是根据 activeIndex.value
+    const needReview = index === 2 ? 1 : null; // 待复核需要 needReview=1
+    const includePrescription = index === 0 ? false : true; // 待完成不需要处方,其他需要
     return VE_API.z_farm_work_record
         .getSimpleList({ role: 2, location, flowStatus, needReview, includePrescription })
         .then(({ data }) => {
             if (Array.isArray(data)) {
                 taskCounts.value[index] = data.length;
+                console.log('taskCounts.value', taskCounts.value);
                 calendarRef.value && calendarRef.value.setCounts(index, taskCounts.value[index]);
 
                 if (index === 0) {
@@ -265,6 +267,8 @@ onMounted(() => {
 });
 
 onActivated(() => {
+    // 初始化时获取所有状态的数量
+    initTaskCounts();
     getSimpleList();
 });
 
@@ -321,8 +325,8 @@ function getSimpleList() {
             // 如果有日期筛选,在前端再次过滤(确保数据准确)
             if (filterDate.value && Array.isArray(filteredData)) {
                 filteredData = filteredData.filter((item) => {
-                    if (!item.executeDate) return false;
-                    const itemDate = formatDate(new Date(item.executeDate));
+                    if (!item.expectedExecuteDate && !item.executeDeadlineDate) return false;
+                    const itemDate = formatDate(new Date(item.expectedExecuteDate || item.executeDeadlineDate));
                     return itemDate === filterDate.value;
                 });
             }
@@ -334,7 +338,6 @@ function getSimpleList() {
                 if (activeIndex.value === 0) {
                     // 传递给日历的数据应该是完整的未筛选数据
                     const calendarData = filterDate.value ? fullTaskList.value : taskList.value;
-                    console.log("calendarData", calendarData);
                     calendarRef.value && calendarRef.value.setSolarTerm(calendarData);
                     // 地图使用筛选后的数据
                     indexMap.initData(taskList.value);
@@ -366,9 +369,9 @@ const handleDateSelect = (date) => {
         // 有日期选择,切换到"待完成"筛选并设置筛选日期
         filterDate.value = date;
         // 如果当前不是"待完成"状态,切换到"待完成"
-        if (activeIndex.value !== 2) {
+        if (activeIndex.value !== 0) {
             isDateSelecting.value = true; // 标记正在通过日期选择切换
-            activeIndex.value = 2;
+            activeIndex.value = 0;
             // watch 会处理 getSimpleList
         } else {
             // 如果已经是"待完成"状态,直接重新加载列表
@@ -389,24 +392,6 @@ function handleActiveFilter(i) {
     selectParma.value.farmWorkTypeId = null;
 }
 
-function toPage(item) {
-    // router.push("/servicZes_agri")
-    // if (activeIndex.value === 2) {
-    // } else {
-    //     // 下发农事请求
-    //     const data = {
-    //         id: item.id,
-    //     };
-    //     VE_API.z_farm_work_record.issueFarmWorkRecord(data).then((res) => {
-    //         if (res.code === 0) {
-    //             taskPopupType.value = "success";
-    //             showTaskPopup.value = true;
-    //             getSimpleList();
-    //         }
-    //     });
-    // }
-}
-
 const offerPopupRef = ref(null);
 const showUploadExecutePopup = (item) => {
     if(getButtonText(item)) {

+ 5 - 5
src/views/old_mini/user/farmDetails.vue

@@ -12,10 +12,10 @@
                 }"
                 @click="handleFarmInfo"
             >
-                <!-- <template #right>
-                    <div @click="handleFarmInfo">基本信息</div>
-                </template> -->
-                <template #footerData>
+                <template #right>
+                    <div @click="handleDetail('plan')">农事规划</div>
+                </template>
+                <!-- <template #footerData>
                     <div class="footer-data">
                         <div class="footer-l">
                             <div class="farm-info-footer-item">
@@ -29,7 +29,7 @@
                         </div>
                         <div class="footer-action" @click.stop="handleDetail('plan')">农事规划</div>
                     </div>
-                </template>
+                </template> -->
             </farm-info-card>
             <tabs v-model:active="activeTab" class="custom-tabs" scrollspy sticky offset-top="40" background="#F2F3F5">
                 <tab title="作物档案" class="tab-item">

+ 3 - 3
src/views/old_mini/user/index.vue

@@ -64,7 +64,7 @@
                                         <div class="farm-info-footer-item-value">{{ ele.serviceCost?.totalCost || 0 }}<span class="unit">元</span></div>
                                     </div>
                                 </div>
-                                <div class="footer-action" @click.stop="handleDetail('plan', ele.id, ele.agriculturalStoreId)">农事规划</div>
+                                <div class="footer-action" @click.stop="handleDetail('plan', ele.id, ele.agriculturalStoreId, ele.schemeId)">农事规划</div>
                             </div>
                         </template>
                     </farm-info-card>
@@ -226,8 +226,8 @@ const handleItemClick = (data) => {
     router.push(`/farm_details?farmId=${data.id}&agriculturalStoreId=${data.agriculturalStoreId}&receiveUserId=${data.receiveUserId}`);
 };
 
-const handleDetail = (path, farmId, agriculturalStoreId) => {
-    router.push(`/${path}?farmId=${farmId}&agriculturalStoreId=${agriculturalStoreId}`);
+const handleDetail = (path, farmId, agriculturalStoreId, schemeId) => {
+    router.push(`/${path}?farmId=${farmId}&agriculturalStoreId=${agriculturalStoreId}&schemeId=${schemeId}`);
 };
 </script>