Переглянути джерело

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

wangsisi 1 день тому
батько
коміт
62d05b0a30

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

@@ -75,4 +75,9 @@ module.exports = {
         url: url + "/addExecuteImgAndComplete",
         type: "post",
     },
+    // 更新农事记录的预计执行日期
+    updateExpectedExecuteDate: {
+        url: url + "/updateExpectedExecuteDate",
+        type: "get",
+    },
 }

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

@@ -53,7 +53,7 @@
                             v-for="(item, index) in executorList"
                             :key="index"
                             :label="item.name"
-                            :value="item.id"
+                            :value="item.miniUserId"
                         />
                     </el-select>
                 </div>
@@ -140,18 +140,7 @@ const type = ref(null);
 const arrangeId = ref(null);
 // 选择执行人
 const needExecutor = ref(false);
-const executorList = ref([
-    {
-        id: 1,
-        name: "张三",
-        phone: "13800138000",
-    },
-    {
-        id: 2,
-        name: "李四",
-        phone: "13800138001",
-    },
-]);
+const executorList = ref([]);
 const executorId = ref(null);
 const needReview = ref(false);
 const reviewDay = ref(null);
@@ -180,8 +169,7 @@ function handleShow({
     show.value = true;
     type.value = typeVal;
     arrangeId.value = arrangeIdVal;
-    // executorList.value = executorListVal;
-    console.log("executorList222222", executorListVal);
+    executorList.value = executorListVal;
     imgDesc.value = imgDescVal;
     needExecutor.value = needExecutorVal;
     selectCurrentPhenology.value = selectCurrentPhenologyVal ? true : false;
@@ -201,12 +189,22 @@ const handleUpload = () => {
     if (isUploading.value) return;
 
     if (images.value.length === 0) return ElMessage.warning("请上传图片");
-    const paramsObj = {
+    let paramsObj = {
         farmId: gardenId.value,
         arrangeId: arrangeId.value,
         executeDate: formatDate(uploadDate.value),
         imagePaths: images.value,
     };
+    if (needExecutor.value) {
+        paramsObj = {
+            ...paramsObj,
+            executeDeadlineDate: formatDate(uploadDate.value),
+            executeDate: null,
+            executorUserId: executorId.value,
+            needReview: needReview.value,
+            reviewIntervalDays: reviewDay.value,
+        };
+    }
     if (type.value === "question") {
         show.value = false;
         emit("handleUploadSuccess", paramsObj);
@@ -221,6 +219,7 @@ function triggerFarmWork(paramsObj, showSuccess) {
 
     // 设置上传状态为 true
     isUploading.value = true;
+    console.log("paramsObj", paramsObj);
 
     VE_API.monitor
         .triggerFarmWork(paramsObj)
@@ -228,7 +227,8 @@ function triggerFarmWork(paramsObj, showSuccess) {
             if (res.code === 0) {
                 if (showSuccess) {
                     show.value = false;
-                    successShow.value = true;
+                    // successShow.value = true;
+                    ElMessage.success("农事已转入成功");
                     emit("handleUploadSuccess", paramsObj);
                 }
             }

+ 34 - 3
src/components/popup/offerPopup.vue

@@ -64,7 +64,7 @@
                     class="uploader"
                     v-model="fileList"
                     multiple
-                    :max-count="3"
+                    :max-count="5"
                     :after-read="afterRead"
                     @click="handleClick('rg')"
                 >
@@ -204,6 +204,10 @@ const afterRead = (file) => {
         // fileList.value[index].url = base_img_url2 + resFilename;
         // fileArr.value.push(base_img_url2 + resFilename)
         fileArr.value.push(resFilename);
+    }).catch(() => {
+        file.status = 'failed';
+        file.message = '上传失败';
+        ElMessage.error('图片上传失败,请稍后再试!')
     });
 };
 
@@ -230,10 +234,37 @@ function handleNextStep() {
         }
     });
 }
+
+function formatDate(date) {
+    let year = date.getFullYear();
+    let month = String(date.getMonth() + 1).padStart(2, "0");
+    let day = String(date.getDate()).padStart(2, "0");
+    return `${year}-${month}-${day}`;
+}
+
+const emit = defineEmits(['uploadSuccess']);
 function closeTask() {
     // stepIndex.value = 2
-    show.value = false;
-    router.push("/review_work");
+    if (!fileArr.value.length || fileArr.value.length < 2) return ElMessage.warning('请上传至少两张图片')
+    if (!executeTime.value) return ElMessage.warning('请选择实际执行时间')
+    const params = {
+        recordId: executionData.value.id,
+        executeDate: formatDate(executeTime.value),
+        executeEvidence: fileArr.value,
+        actualAgriculturalInput: formData.agriculturalInput,
+        actualFarmServiceInput: formData.serviceInput,
+        actualTotalInput: formData.totalAmount,
+    }
+    VE_API.z_farm_work_record.addExecuteImgAndComplete(params).then((res) => {
+        if (res.code === 0) {
+            ElMessage.success('上传成功')
+            show.value = false
+            emit('uploadSuccess')
+        }
+    })
+    // show.value = false;
+
+    // router.push("/review_work");
 
     // if(!input.value.length) return ElMessage.warning('请上传图片')
     // const params = {

+ 56 - 88
src/components/taskItem.vue

@@ -3,17 +3,22 @@
         <div class="item-top">
             <div class="top-l">
                 <div class="item-name">{{ itemData?.farmWorkName }}</div>
-                <div class="item-time">{{ itemData?.executeDate }}</div>
+                <div class="item-time" v-if="itemIndex === 0">
+                    {{
+                        itemData?.expectedExecuteDate
+                            ? itemData?.expectedExecuteDate
+                            : itemData?.executeDeadlineDate
+                            ? "截止到" + itemData?.executeDeadlineDate
+                            : ""
+                    }}
+                </div>
+                <div class="item-time" v-else>{{ itemData?.executeDate }}</div>
             </div>
             <div class="top-r" @click="toDetail(props.status, itemData.id, itemData.farmWorkLibId)">
                 {{ props.status === 0 ? "查看处方" : "查看详情" }}
             </div>
         </div>
         <div class="item-box" v-if="props.status === 0">
-            <div class="farm-text" v-if="(props.status === 0 && itemIndex === 0) || isHall">
-                <span class="text-title">农场现状:</span>{{ farmStatusText }}
-                <!-- <span class="text-more">点击查看照片</span> -->
-            </div>
             <div class="img-text-wrap">
                 <div class="left-wrap">
                     <div class="left-img">
@@ -30,9 +35,7 @@
                                 <!-- <div class="tag-item second">
                                     普通客户
                                 </div> -->
-                                <div class="tag-item warning">
-                                    托管客户
-                                </div>
+                                <div class="tag-item warning">托管客户</div>
                             </div>
                         </div>
                         <div class="farm-addr">{{ itemData?.address }}</div>
@@ -56,24 +59,29 @@
                         <span class="value">{{ prescriptionText }}</span>
                     </div>
                 </div>
-                <div class="desc-info two-text" v-if="!expiredDay">
+                <div class="desc-info" v-if="itemIndex === 2 && daysDiff > 0">
                     <div class="desc-info-item">
-                        <div>复核成效</div>
-                        <span class="value"
-                            >促进分蘖芽萌发、加快分蘖生长,同时补充氮素等关键养分,增强植株长势,为形成足够穗数、提高群体产量打基础。</span
+                        <span>复核时间:</span>
+                        <span class="value">{{ itemData?.executeDate }}</span>
+                    </div>
+                </div>
+                <div class="desc-info" v-if="itemIndex === 2">
+                    <div class="desc-info-item expired-text">
+                        <span
+                            >距离农事执行已 <span class="val-text">{{ daysDiff }}</span
+                            >天,请抓紧时间复核!</span
                         >
                     </div>
                 </div>
-                <div class="review-image" v-if="!expiredDay">
-                    <div class="review-image-item" v-if="detailItem?.executeEvidence?.length">
-                        <div class="review-image-item-title">执行照片</div>
+                <div class="review-image" v-if="itemData?.executeEvidence?.length">
+                    <div class="review-image-item">
                         <photo-provider :photo-closable="true">
                             <photo-consumer
-                                v-for="src in [detailItem.executeEvidence[detailItem.executeEvidence.length - 1]]"
-                                intro="农事后照片"
+                                v-for="src in JSON.parse(itemData.executeEvidence)"
                                 :key="src"
                                 :src="base_img_url2 + src"
                             >
+                                <div class="review-image-item-title">执行照片</div>
                                 <div class="img-item">
                                     <img :src="base_img_url2 + src + resize" class="view-box" />
                                 </div>
@@ -81,27 +89,11 @@
                         </photo-provider>
                     </div>
                 </div>
-
-                <!-- 过期农事 -->
-                <div v-if="expiredDay">
-                    <div class="desc-info pt-10">
-                        <div class="desc-info-item">
-                            <span>复核时间:</span>
-                            <span class="value">2025.10.27</span>
-                            <span class="expired-day">(已过期1天)</span>
-                        </div>
-                    </div>
-                    <div class="desc-info">
-                        <div class="expired-text">
-                            距离农事执行已 <span class="val-text">15</span>天,提醒用户拍照,增加信誉度!
-                        </div>
-                    </div>
-                </div>
             </div>
 
             <slot name="footer"></slot>
 
-            <div class="item-footer" v-if="props.status === 1">
+            <!-- <div class="item-footer" v-if="props.status === 1">
                 <div
                     class="footer-l farm-name-text van-ellipsis"
                     :style="{ width: detailItem?.reviewImage?.length ? 'calc(100% - 100px)' : 'calc(100% - 180px)' }"
@@ -110,12 +102,8 @@
                 </div>
                 <div class="footer-r">
                     <div class="btn warning" @click="generateReport">生成成果报告</div>
-                    <!-- <template v-else>
-                        <div class="btn secondary-text" @click="remindUser">提醒用户拍照</div>
-                        <div class="btn photo-text" @click="handleUploadPhoto">上传照片</div>
-                    </template> -->
                 </div>
-            </div>
+            </div> -->
         </div>
     </div>
 
@@ -134,7 +122,7 @@
 </template>
 
 <script setup>
-import { onMounted, ref } from "vue";
+import { onMounted, ref, computed } from "vue";
 import { useRouter } from "vue-router";
 import { base_img_url2 } from "@/api/config";
 import { ElMessage, ElMessageBox } from "element-plus";
@@ -164,7 +152,6 @@ const props = defineProps({
     },
 });
 
-const expiredDay = ref(0); // 过期天数
 const uploadExecuteRef = ref(null);
 const router = useRouter();
 const detailDialogRef = ref(null);
@@ -181,7 +168,7 @@ const handleFollow = ({ farmId, isFollow }) => {
     })
         .then(() => {
             const api = isFollow ? VE_API.z_farm_work_record.unfollowFarm : VE_API.z_farm_work_record.followFarm;
-            api({ farmId }).then(({ code,msg }) => {
+            api({ farmId }).then(({ code, msg }) => {
                 if (code === 0) {
                     ElMessage.success(msg);
                     emit("handleFollowSuccess");
@@ -193,24 +180,25 @@ const handleFollow = ({ farmId, isFollow }) => {
         .catch(() => {});
 };
 
-const generateReport = () => {
-    router.push({
-        path: "/achievement_report",
-        query: { miniJson: JSON.stringify({ id: detailItem.value.id }) },
-    });
-};
-
-const shareResult = () => {
-    if (detailItem.value?.reviewImage?.length) {
-        const preImg = triggerImg.value.length
-            ? base_img_url2 + triggerImg.value[triggerImg.value.length - 1].cloudFilename
-            : "";
-        const resImg = detailItem.value?.reviewImage?.length
-            ? base_img_url2 + detailItem.value.reviewImage[detailItem.value.reviewImage.length - 1]
-            : "";
-        reviewPopupRef.value.handleShowPopup(detailItem.value.id, preImg, resImg);
+// 计算距离执行时间的天数差
+const daysDiff = computed(() => {
+    if (!props.itemData?.executeDate) {
+        return 0;
     }
-};
+
+    const executeDate = new Date(props.itemData.executeDate);
+    const today = new Date();
+
+    // 将时间设置为 00:00:00,只比较日期
+    executeDate.setHours(0, 0, 0, 0);
+    today.setHours(0, 0, 0, 0);
+
+    // 计算天数差(毫秒转天数)
+    const diffTime = executeDate.getTime() - today.getTime();
+    const diffDays = Math.floor(diffTime / (1000 * 60 * 60 * 24));
+
+    return diffDays;
+});
 
 const remindUser = () => {
     uploadExecuteRef.value.showPopup({ ...props.itemData, type: "remindUser" });
@@ -225,13 +213,7 @@ const handleUploadPhoto = () => {
 
 const emit = defineEmits(["handleUploadSuccess", "handleFollowSuccess"]);
 
-const triggerImg = ref([]);
 const detailItem = ref({});
-const getTriggerImg = async () => {
-    if (!detailItem.value?.id) return;
-    const { data } = await VE_API.z_farm_work_record.getTriggerImg({ farmWorkRecordId: detailItem.value.id });
-    triggerImg.value = data || [];
-};
 
 // 更新触发图片(上传成功后调用)
 const updateTriggerImg = async () => {
@@ -239,11 +221,6 @@ const updateTriggerImg = async () => {
 
     // 重新获取详情
     await getItemDetail(props.itemData.id);
-
-    // 如果是已完成状态(status === 1),需要重新获取触发图片
-    if (props.status === 1) {
-        await getTriggerImg();
-    }
     // 如果是待完成状态(status === 0),详情已经更新,itemData 会在 getSimpleList 后更新
 };
 
@@ -260,22 +237,9 @@ onMounted(async () => {
         if (Array.isArray(detailItem.value?.prescriptionList)) {
             prescriptionText.value = buildPrescriptionText(detailItem.value.prescriptionList);
         }
-
-        getTriggerImg();
-    }
-    if (props.itemIndex === 0 && props.itemData?.farmWorkArrangeId) {
-        getFarmWorkArrangeDetail(props.itemData.farmWorkArrangeId);
     }
 });
 
-// 获取农场现状
-const farmStatusText = ref('');
-const getFarmWorkArrangeDetail = (id) => {
-    VE_API.farm.getFarmWorkArrangeDetail({ id }).then(({ data }) => {
-        farmStatusText.value = data.farmStatus;
-    });
-};
-
 // 将所有需要暴露的方法放在 defineExpose 中
 defineExpose({
     updateTriggerImg,
@@ -530,7 +494,7 @@ const toDetail = (status, id, farmWorkId) => {
                                 background: #e8f3ff;
                             }
                             &.warning {
-                                color: #FF953D;
+                                color: #ff953d;
                                 background: rgba(255, 149, 61, 0.1);
                             }
                         }
@@ -594,6 +558,9 @@ const toDetail = (status, id, farmWorkId) => {
                     color: #666666;
                 }
             }
+            .expired-text {
+                background: linear-gradient(90deg, rgba(33, 153, 248, 0.2) 0%, rgba(33, 153, 248, 0) 100%);
+            }
             &.two-text {
                 .value {
                     font-size: 12px;
@@ -624,11 +591,11 @@ const toDetail = (status, id, farmWorkId) => {
         }
 
         .review-image {
-            display: flex;
-            align-items: center;
-            gap: 8px;
             padding-top: 6px;
             .review-image-item {
+                display: flex;
+                align-items: center;
+                gap: 8px;
                 position: relative;
                 flex: 1;
                 .review-image-item-title {
@@ -646,6 +613,7 @@ const toDetail = (status, id, farmWorkId) => {
                     .PhotoConsumer {
                         width: 100%;
                         height: 100%;
+                        position: relative;
                     }
                 }
             }
@@ -653,7 +621,7 @@ const toDetail = (status, id, farmWorkId) => {
                 width: 100%;
                 height: 106px;
                 object-fit: cover;
-                border-radius: 4px;
+                border-radius: 8px;
             }
         }
         .copy-info {

+ 2 - 0
src/components/upload.vue

@@ -90,6 +90,8 @@ const afterRead = async (files) => {
         emit('handleUpload',{imgArr:imgArr.value,fileList:fileArr.value})
       }else{
         fileList.value.pop()
+        file.status = 'failed';
+        file.message = '上传失败';
         ElMessage.error('图片上传失败,请稍后再试!')
       }
     }

+ 1 - 1
src/views/old_mini/farm_manage/map/index.js

@@ -216,7 +216,7 @@ class IndexMap {
     this.gardenPointLayer.source.clear();
     if (taskList.length > 0) {  // 如果任务列表不为空,则添加任务点
       for (let item of taskList) {
-        item.mapInfo = label ? item[label] : item.executeDate?.replace(/^\d{4}-(\d{2})-(\d{2})$/, '$1.$2') + '  ' + item.farmWorkName
+        item.mapInfo = label ? item[label] : (item.executeDeadlineDate || item.executeDate)?.replace(/^\d{4}-(\d{2})-(\d{2})$/, '$1.$2') + '  ' + item.farmWorkName
         this.gardenPointLayer.source.addFeature(newPoint(item, "point", "myGarden"))
       }
       this.kmap.getView().fit(this.gardenPointLayer.source.getExtent(), { padding: [42, 20, 30, 20] });

+ 16 - 6
src/views/old_mini/home/components/AgriculturalDynamics.vue

@@ -54,7 +54,7 @@
                                 </div>
                                 <div class="text">
                                     预计报价<span class="price">{{ timelineItem.estimatedCost }}元</span>
-                                    <span class="action-detail">查看报价单</span>
+                                    <span class="action-detail" @click="showPriceSheetPopup(timelineItem)">查看报价单</span>
                                 </div>
                             </div>
                             <div class="timeline-action" @click="handleTimelineAction(timelineItem, item.farmId)">
@@ -69,6 +69,9 @@
     <offer-popup ref="offerPopupRef"></offer-popup>
     <!-- 新增:激活上传弹窗 -->
     <active-upload-popup ref="activeUploadPopupRef" @handleUploadSuccess="handleUploadSuccess"></active-upload-popup>
+    
+    <!-- 服务报价单 -->
+    <price-sheet-popup ref="priceSheetPopupRef"></price-sheet-popup>
 </template>
 
 <script setup>
@@ -77,6 +80,7 @@ import { ref, onMounted } from "vue";
 import offerPopup from "@/components/popup/offerPopup.vue";
 import eventBus from "@/api/eventBus";
 import activeUploadPopup from "@/components/popup/activeUploadPopup.vue";
+import priceSheetPopup from "@/components/popup/priceSheetPopup.vue";
 // 任务列表数据
 const taskList = ref([
     { id: 1, title: "梢期杀虫", executionTime: "2025.05.06", status: "pending" },
@@ -114,13 +118,10 @@ const handleTaskAction = (item) => {
 
 // 查询当前农资店的成员列表(只保留有“任务接单”权限的成员)
 const getManagerList = async () => {
-    const { data } = await VE_API.mine.listManagerList();
+    const { data } = await VE_API.mine.listManagerList({onlyExecutor: true});
     if (data && data.length > 0) {
         // 过滤 permissionList 中包含“任务接单”的成员
-        executorList.value = data.filter((item) => {
-            const list = item.permissionList || [];
-            return Array.isArray(list) && list.includes("任务接单");
-        });
+        executorList.value = data;
     }
 };
 
@@ -137,6 +138,15 @@ const handleTimelineAction = (item, farmId) => {
     });
 };
 
+
+const priceSheetPopupRef = ref(null);
+const showPriceSheetPopup = (item) => {
+    VE_API.z_farm_work_record.getDetail({ id: item.farmWorkId }).then(({ data }) => {
+        const res = data[0];
+        priceSheetPopupRef.value.handleShowPopup(res);
+    });
+};
+
 const handleUploadSuccess = async () => {
     await getUnansweredFarms();
 };

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

@@ -1695,7 +1695,7 @@ const handleDeleteInteract = () => {
         padding: 10px 0;
         line-height: 20px;
         color: #919191;
-        font-size: 12px;
+        font-size: 14px;
     }
     .interact-form {
         padding: 8px 0 20px 0px;

+ 90 - 55
src/views/old_mini/task_condition/components/task.vue

@@ -3,19 +3,19 @@
         <div class="task-top">
             <div class="map-container" ref="mapContainer"></div>
             <div class="calendar-wrap">
-                <calendar ref="calendarRef" @dateSelect="handleDateSelect"></calendar>
+                <customCalendar ref="calendarRef" @dateSelect="handleDateSelect"></customCalendar>
             </div>
         </div>
         <div class="task-list">
             <div class="list-filter">
-                <div class="filter-item" :class="{ active: activeIndex === 2 }" @click="handleActiveFilter(2)">
-                    待完成({{ taskCounts[2] || 0 }})
-                </div>
-                <div class="filter-item" :class="{ active: activeIndex === 3 }" @click="handleActiveFilter(3)">
-                    已完成({{ taskCounts[3] || 0 }})
+                <div class="filter-item" :class="{ active: activeIndex === 0 }" @click="handleActiveFilter(0)">
+                    待完成({{ taskCounts[0] || 0 }})
                 </div>
                 <div class="filter-item" :class="{ active: activeIndex === 1 }" @click="handleActiveFilter(1)">
-                    已复核({{ taskCounts[1] || 0 }})
+                    已完成({{ taskCounts[1] || 0 }})
+                </div>
+                <div class="filter-item" :class="{ active: activeIndex === 2 }" @click="handleActiveFilter(2)">
+                    已复核({{ taskCounts[2] || 0 }})
                 </div>
             </div>
             <div class="select-group">
@@ -43,27 +43,43 @@
                     <task-item
                         :key="activeIndex + '-' + index"
                         :itemIndex="activeIndex"
-                        :status="activeIndex === 3 ? 1 : 0"
+                        :status="activeIndex === 0 ? 0 : 1"
                         :item-data="item"
                         @handleUploadSuccess="handleUploadSuccess"
                         :ref="(el) => setTaskItemRef(el, index)"
                     >
                         <template #footer>
                             <div class="item-footer" v-if="activeIndex === 2">
-                                <div class="footer-l" @click="toDetail(item)">查看详情</div>
-                                <div class="footer-r">
-                                    <div class="btn primary" @click="showUploadExecutePopup(item)">
-                                        请求确认
+                                <div
+                                        class="footer-l farm-name-text van-ellipsis"
+                                    >
+                                        来自<span class="name-text">{{ item.farmName || "--" }}</span>
                                     </div>
+                                <div class="footer-r">
+                                    <div class="btn primary" @click="handleAction(item)">上传复核照片</div>
                                 </div>
                             </div>
                             <div v-else-if="activeIndex === 1" class="item-footer">
-                                <div class="footer-l" @click="toDetail(item)">查看详情</div>
+                                <div
+                                        class="footer-l farm-name-text van-ellipsis"
+                                    >
+                                        来自<span class="name-text">{{ item.farmName || "--" }}</span>
+                                    </div>
                                 <div class="footer-r">
-                                    <!-- <div class="btn second" @click="handleForward(item)">
-                                        转发给客户
-                                    </div> -->
-                                    <div class="btn primary" @click="showPriceSheetPopup(item)">确认并报价</div>
+                                    <div class="btn warning" @click="generateReport(item)">生成成果报告</div>
+                                </div>
+                            </div>
+                            <div v-else-if="activeIndex === 0" class="item-footer">
+                                <div class="footer-l" @click="toDetail(item)">查看详情</div>
+                                <div class="footer-r" v-if="item.expectedExecuteDate">
+                                    <div class="btn primary" @click="showUploadExecutePopup(item)">
+                                        上传照片
+                                    </div>
+                                </div>
+                                <div class="footer-r" v-else>
+                                    <div class="btn warning" @click="selectExecuteTime(item)">
+                                        确认执行时间
+                                    </div>
                                 </div>
                             </div>
                         </template>
@@ -77,16 +93,19 @@
 
     <!-- 服务报价单 -->
     <price-sheet-popup :key="activeIndex" ref="priceSheetPopupRef"></price-sheet-popup>
-    <offer-popup ref="offerPopupRef"></offer-popup>
+    <offer-popup ref="offerPopupRef" @uploadSuccess="handleUploadSuccess"></offer-popup>
+
+    <!-- 确认执行时间 -->
+    <calendar teleport="#app" v-model:show="showCalendar" @confirm="onConfirmExecuteTime" :min-date="minDate" :max-date="maxDate" />
 </template>
 
 <script setup>
 import { computed, nextTick, onMounted, ref, watch } from "vue";
 import { useStore } from "vuex";
-import { Popup } from "vant";
+import { Popup, Calendar } from "vant";
 import IndexMap from "../../farm_manage/map/index";
 import taskItem from "@/components/taskItem.vue";
-import calendar from "./calendar.vue";
+import customCalendar from "./calendar.vue";
 import { useRouter } from "vue-router";
 import uploadExecute from "./uploadExecute.vue";
 import priceSheetPopup from "@/components/popup/priceSheetPopup.vue";
@@ -115,7 +134,7 @@ const fullTaskList = ref([]);
 // 各状态任务数量
 const taskCounts = ref([0, 0, 0]);
 // 当前选中的筛选索引
-const activeIndex = ref(2);
+const activeIndex = ref(0);
 // 筛选日期(用于按日期筛选)
 const filterDate = ref(null);
 const noData = ref(false);
@@ -124,24 +143,26 @@ const loading = ref(false);
 // 根据 activeIndex 计算 startFlowStatus
 const getStartFlowStatus = (index) => {
     const statusMap = {
-        1: 4, // 待完成
-        2: 5, // 已完成
-        3: 5, // 待复核
+        0: 4, // 待完成
+        1: 5, // 已完成
+        2: 5, // 待复核
     };
     return statusMap[index] ?? 4;
 };
 
 // 获取单个状态的任务数量
-function getTaskCount(flowStatus, index, needReview) {
+function getTaskCount(flowStatus, index) {
     const location = store.state.home.miniUserLocationPoint;
+    const needReview = activeIndex.value === 2 ? 1 : null;
+    const includePrescription = activeIndex.value === 0 ? false : true;
     return VE_API.z_farm_work_record
-        .getSimpleList({ role: 2, location, flowStatus, needReview })
+        .getSimpleList({ role: 2, location, flowStatus, needReview, includePrescription })
         .then(({ data }) => {
             if (Array.isArray(data)) {
                 taskCounts.value[index] = data.length;
                 calendarRef.value && calendarRef.value.setCounts(index, taskCounts.value[index]);
 
-                if (index === 2) {
+                if (index === 0) {
                     calendarRef.value && calendarRef.value.setSolarTerm(data);
                     indexMap.initData(data);
                 }
@@ -165,21 +186,8 @@ const setTaskItemRef = (el, index) => {
 };
 
 const handleUploadSuccess = async () => {
-    // 先保存当前需要更新的 item id
-    const currentItemIds = taskList.value.map((item) => item.id || item.workRecordId);
-
     // 刷新列表
     await getSimpleList();
-
-    // 等待 DOM 更新完成,refs 被重新收集
-    await nextTick();
-
-    // 更新所有task-item的triggerImg
-    taskItemRefs.value.forEach((ref) => {
-        if (ref && ref.updateTriggerImg) {
-            ref.updateTriggerImg();
-        }
-    });
 };
 
 const cityCode = ref("");
@@ -210,9 +218,9 @@ function initTaskCounts() {
     const location = store.state.home.miniUserLocationPoint;
     // 并行请求状态的数量
     Promise.all([
-        getTaskCount(4, 1), // 已确认
-        getTaskCount(5, 2), // 待完成
-        getTaskCount(5, 3, true), // 已完成
+        getTaskCount(4, 0), // 待完成
+        getTaskCount(5, 1), // 已完成
+        getTaskCount(5, 2), // 待复核
     ]);
 }
 const mapPoint = ref(null);
@@ -257,7 +265,7 @@ function getSimpleList() {
     // 清空refs数组,避免索引错乱
     taskItemRefs.value = [];
     const startFlowStatus = getStartFlowStatus(activeIndex.value);
-    const needReview = activeIndex.value === 2 ? true : false;
+    const needReview = activeIndex.value === 2 ? 1 : null;
     const params = {
         ...selectParma.value,
         role: 2,
@@ -265,6 +273,7 @@ function getSimpleList() {
         flowStatus: startFlowStatus,
         farmWorkTypeId: selectParma.value.farmWorkTypeId || null,
         needReview: needReview,
+        includePrescription: activeIndex.value === 0 ? false : true,
     };
 
     return VE_API.z_farm_work_record
@@ -293,7 +302,7 @@ function getSimpleList() {
                 taskList.value = filteredData;
                 // 更新当前状态的数量
                 taskCounts.value[activeIndex.value] = filteredData.length;
-                if (activeIndex.value === 2) {
+                if (activeIndex.value === 0) {
                     // 传递给日历的数据应该是完整的未筛选数据
                     const calendarData = filterDate.value ? fullTaskList.value : taskList.value;
                     calendarRef.value && calendarRef.value.setSolarTerm(calendarData);
@@ -311,7 +320,7 @@ function getSimpleList() {
             loading.value = false;
             taskList.value = [];
             taskCounts.value[activeIndex.value] = 0;
-            if (activeIndex.value === 2) {
+            if (activeIndex.value === 0) {
                 // 即使筛选后没有数据,日历也应该显示完整数据
                 const calendarData = filterDate.value ? fullTaskList.value : [];
                 indexMap.initData(taskList.value);
@@ -382,17 +391,16 @@ function toPage(item) {
 const offerPopupRef = ref(null);
 const showUploadExecutePopup = (item) => {
     offerPopupRef.value.openPopup(item);
-    // if (item?.executeEvidence.length) {
-    //     onlyShare.value = true;
-    // } else {
-    //     onlyShare.value = false;
-    // }
-    // setTimeout(() => {
-    //     uploadExecuteRef.value.showPopup(item);
-    // }, 10);
 };
 
 
+const generateReport = (item) => {
+    router.push({
+        path: "/achievement_report",
+        query: { miniJson: JSON.stringify({ id: item.id }) },
+    });
+};
+
 function toDetail(item) {
     // router.push({
     //         path: "/modify",
@@ -404,6 +412,27 @@ function toDetail(item) {
     });
 }
 
+const showCalendar = ref(false);
+const maxDate = ref();
+const minDate = new Date(2010, 0, 1);
+const executeItem = ref(null);
+const selectExecuteTime = (item) => {
+    executeItem.value = item;
+    maxDate.value = new Date(item.executeDeadlineDate);
+    showCalendar.value = true;
+};
+
+const onConfirmExecuteTime = (date) => {
+    showCalendar.value = false;
+    VE_API.z_farm_work_record.updateExpectedExecuteDate({ recordId: executeItem.value.id, expectedExecuteDate: formatDate(date) }).then((res) => {
+        if (res.code === 0) {
+            ElMessage.success("操作成功");
+            getSimpleList();
+        }
+    });
+};
+
+
 const priceSheetPopupRef = ref(null);
 const showPriceSheetPopup = (item) => {
     VE_API.z_farm_work_record.getDetail({ id: item.id }).then(({ data }) => {
@@ -414,7 +443,6 @@ const showPriceSheetPopup = (item) => {
 
 const onlyShare = ref(false);
 function handleAction(item) {
-    onlyShare.value = true;
     setTimeout(() => {
         uploadExecuteRef.value.showPopup(item, "share-sheet");
     }, 10);
@@ -611,3 +639,10 @@ function handleForward(item) {
     }
 }
 </style>
+
+<style lang="scss">
+
+.van-calendar__popup {
+    z-index: 9999 !important;
+}
+</style>

+ 10 - 10
src/views/old_mini/task_condition/components/uploadExecute.vue

@@ -8,16 +8,16 @@
         <div class="header">
             <div class="title">
                 <span class="required">*</span>
-                请上传执行照片
+                请上传复核照片
             </div>
         </div>
         <upload ref="uploadRef" exampleImg class="upload-wrap" @handleUpload="handleUpload">
             <img class="example" src="@/assets/img/home/example-4.png" alt="" />
             <img class="example" src="@/assets/img/home/plus.png" alt="">
         </upload>
-        <div class="btn" @click="handleConfirm">请求确认</div>
+        <div class="btn" @click="handleConfirm">确认上传</div>
     </popup>
-    <FnShareSheet v-model:show="showShare" @select="onSelect" :class="className" />
+    <!-- <FnShareSheet v-model:show="showShare" @select="onSelect" :class="className" /> -->
 </template>
 
 <script setup>
@@ -45,13 +45,13 @@ const className = ref(null);
 const farmWorkRecordId = ref(null);
 const farmData = ref({});
 function showPopup(data,classNameVal) {
-    if (props.onlyShare) {
-        showShare.value = true;
-        className.value = classNameVal;
-    } else {
-        show.value = true;
-        farmWorkRecordId.value = data.id;
-    }
+    // if (props.onlyShare) {
+    //     showShare.value = true;
+    //     className.value = classNameVal;
+    // } else {
+    // }
+    show.value = true;
+    farmWorkRecordId.value = data.id;
     farmData.value = data;
 }
 const images = ref([]);