Browse Source

feat:修改bug

wangsisi 2 tuần trước cách đây
mục cha
commit
a32d157f04

+ 14 - 0
src/components/pageComponents/PlanList.vue

@@ -85,6 +85,20 @@ const curRole = localStorage.getItem("SET_USER_CUR_ROLE")
 const menuData = ref([]);
 const containerRef = ref(null);
 
+function getPlanWorkList() {
+    VE_API.monitor
+        .listByFarmId({ farmId: props.farmId })
+        .then(({ data }) => {
+            menuData.value = data;
+        });
+}
+
+watch(() => props.farmId, (newVal) => {
+    if(newVal){
+        getPlanWorkList();
+    }
+});
+
 
 const getFarmTypeText = (type) => {
     const value = typeof type === "string" ? type.trim() : type;

+ 61 - 8
src/components/pageComponents/ServiceInfo.vue

@@ -9,10 +9,10 @@
                 <div class="service-item">
                     <div class="sub-title">服务作物</div>
                     <div class="tag-group" v-if="!isEdit">
-                        <div class="tag-item" v-for="(item, idx) in crops" :key="'c-'+idx">{{ item.name }}</div>
+                        <div class="tag-item" :class="{ selected: item.selected }" @click="handleSelect('crops', idx, $event)" v-for="(item, idx) in crops" :key="'c-'+idx">{{ item.name }}</div>
                     </div>
                     <div class="tag-group add-tag-group" v-else>
-                        <div class="tag-item" :class="{ self: item.isSelf === 1 }" v-for="(item, idx) in crops" :key="'ce-'+idx">
+                        <div class="tag-item" :class="{ self: item.isSelf === 1, selected: item.selected }" @click="handleSelect('crops', idx, $event)" v-for="(item, idx) in crops" :key="'ce-'+idx">
                             <span class="text">{{ item.name }}<el-icon @click.stop="handleEdit(item.name, 'crops')" v-if="item.isSelf===1" class="edit-icon"><Edit /></el-icon></span>
                             <el-icon v-if="item.isSelf===1" class="del-icon" @click.stop="handleDelete('crops', idx)"><Close /></el-icon>
                         </div>
@@ -22,10 +22,10 @@
                 <div class="service-item">
                     <div class="sub-title">服务类型</div>
                     <div class="tag-group" v-if="!isEdit">
-                        <div class="tag-item" v-for="(item, idx) in serviceTypes" :key="'t-'+idx">{{ item.name }}</div>
+                        <div class="tag-item" :class="{ selected: item.selected }" @click="handleSelect('serviceTypes', idx, $event)" v-for="(item, idx) in serviceTypes" :key="'t-'+idx">{{ item.name }}</div>
                     </div>
                     <div class="tag-group add-tag-group" v-else>
-                        <div class="tag-item" :class="{ self: item.isSelf === 1 }" v-for="(item, idx) in serviceTypes" :key="'te-'+idx">
+                        <div class="tag-item" :class="{ self: item.isSelf === 1, selected: item.selected }" @click="handleSelect('serviceTypes', idx, $event)" v-for="(item, idx) in serviceTypes" :key="'te-'+idx">
                             <span class="text">{{ item.name }}<el-icon @click.stop="handleEdit(item.name, 'serviceTypes')" v-if="item.isSelf===1" class="edit-icon"><Edit /></el-icon></span>
                             <el-icon v-if="item.isSelf===1" class="del-icon" @click.stop="handleDelete('serviceTypes', idx)"><Close /></el-icon>
                         </div>
@@ -35,10 +35,10 @@
                 <div class="service-item">
                     <div class="sub-title">农机设备</div>
                     <div class="tag-group" v-if="!isEdit">
-                        <div class="tag-item" v-for="(item, idx) in machines" :key="'m-'+idx">{{ item.name }}</div>
+                        <div class="tag-item" :class="{ selected: item.selected }" @click="handleSelect('machines', idx, $event)" v-for="(item, idx) in machines" :key="'m-'+idx">{{ item.name }}</div>
                     </div>
                     <div class="tag-group add-tag-group" v-else>
-                        <div class="tag-item" :class="{ self: item.isSelf === 1 }" v-for="(item, idx) in machines" :key="'me-'+idx">
+                        <div class="tag-item" :class="{ self: item.isSelf === 1, selected: item.selected }" @click="handleSelect('machines', idx, $event)" v-for="(item, idx) in machines" :key="'me-'+idx">
                             <span class="text">{{ item.name }}<el-icon @click.stop="handleEdit(item.name, 'machines')" v-if="item.isSelf===1" class="edit-icon"><Edit /></el-icon></span>
                             <el-icon v-if="item.isSelf===1" class="del-icon" @click.stop="handleDelete('machines', idx)"><Close /></el-icon>
                         </div>
@@ -146,6 +146,45 @@ function handleEdit(val, category) {
     currentEditIndex.value = targetArray.findIndex(item => item.name === val && item.isSelf === 1);
 }
 
+function handleSelect(category, index, event) {
+    // 如果点击的是编辑图标或删除图标,不触发选中
+    if (event && event.target) {
+        const target = event.target;
+        if (target.closest && (target.closest('.edit-icon') || target.closest('.del-icon'))) {
+            return;
+        }
+    }
+    
+    if (category === 'crops') {
+        const newCrops = [...props.crops];
+        if (newCrops[index]) {
+            if (newCrops[index].selected === undefined) {
+                newCrops[index].selected = false;
+            }
+            newCrops[index].selected = !newCrops[index].selected;
+            emit('update:crops', newCrops);
+        }
+    } else if (category === 'serviceTypes') {
+        const newServiceTypes = [...props.serviceTypes];
+        if (newServiceTypes[index]) {
+            if (newServiceTypes[index].selected === undefined) {
+                newServiceTypes[index].selected = false;
+            }
+            newServiceTypes[index].selected = !newServiceTypes[index].selected;
+            emit('update:serviceTypes', newServiceTypes);
+        }
+    } else if (category === 'machines') {
+        const newMachines = [...props.machines];
+        if (newMachines[index]) {
+            if (newMachines[index].selected === undefined) {
+                newMachines[index].selected = false;
+            }
+            newMachines[index].selected = !newMachines[index].selected;
+            emit('update:machines', newMachines);
+        }
+    }
+}
+
 function handleConfirm() {
     if (!input.value.trim()) {
         return;
@@ -168,7 +207,7 @@ function handleConfirm() {
         }
     } else {
         // 添加模式
-        const newItem = { name: input.value.trim(), isSelf: 1 };
+        const newItem = { name: input.value.trim(), isSelf: 1, selected: false };
         if (currentCategory.value === 'crops') {
             const newCrops = [...props.crops, newItem];
             emit('update:crops', newCrops);
@@ -217,7 +256,7 @@ function handleConfirm() {
                     font-weight: 500;
                     color: rgba(0, 0, 0, 0.9);
                 }
-                .tag-group {
+                    .tag-group {
                     display: flex;
                     align-items: center;
                     flex-wrap: wrap;
@@ -235,6 +274,8 @@ function handleConfirm() {
                         height: 48px;
                         text-align: center;
                         line-height: 48px;
+                        cursor: pointer;
+                        transition: all 0.3s;
                         .text { display: inline-flex; align-items: center; }
                         .edit-icon { margin-left: 8px; }
                         .del-icon {
@@ -248,17 +289,28 @@ function handleConfirm() {
                             display: flex; align-items: center; justify-content: center;
                             color: #fff;
                         }
+                        &.selected {
+                            border: 1px solid #2199F8;
+                            background: #E8F5FF;
+                            color: #2199F8;
+                        }
                     }
                     &.add-tag-group {
                         .tag-item {
                             color: #000000;
                             background: none;
                             border: 1px solid #999999;
+                            cursor: pointer;
                             &.self {
                                 border: 1px solid #2199F8;
                                 background: #E8F5FF;
                                 color: #2199F8;
                             }
+                            &.selected {
+                                border: 1px solid #2199F8;
+                                background: #E8F5FF;
+                                color: #2199F8;
+                            }
                             &.last-add {
                                 background: #F7F7F7;
                                 color: #343434;
@@ -266,6 +318,7 @@ function handleConfirm() {
                                 display: flex;
                                 align-items: center;
                                 justify-content: center;
+                                cursor: pointer;
                                 .add-icon {
                                     font-size: 14px;
                                     font-weight: bold;

+ 5 - 7
src/views/old_mini/farm_manage/components/demandHall.vue

@@ -114,7 +114,6 @@ const mapPoint = ref(null);
 onMounted(() => {
     mapPoint.value = store.state.home.miniUserLocationPoint;
     getFarmWorkTypeList();
-    getSimpleList();
     getDistrictListByCity();
     nextTick(() => {
         indexMap.initMap(mapPoint.value, mapContainer.value, props.isCapital);
@@ -131,7 +130,10 @@ const districtList = ref([]);
 function getDistrictListByCity() {
     VE_API.z_farm_work_record.getDistrictListByCity({ point: mapPoint.value }).then(({ data }) => {
         districtList.value = data || [];
-        districtList.value.unshift({ code: 0, name: "全部" });
+        const cityCode = data[0].code.slice(0, -2);
+        districtList.value.unshift({ code: cityCode, name: "全部" });
+        selectParma.value.districtCode = cityCode;
+        getSimpleList()
     });
 }
 
@@ -152,8 +154,8 @@ const selectParma = ref({
 const taskList = ref([]);
 function getSimpleList() {
     const params = {
+        ...selectParma.value,
         farmWorkTypeId: selectParma.value.farmWorkTypeId || null,
-        districtCode: selectParma.value.districtCode || null,
         location: mapPoint.value,
     };
     VE_API.z_farm_work_record
@@ -208,16 +210,12 @@ function handleLocationChange(data) {
         }
         // 更新区县列表
         getDistrictListByCity();
-        // 重新获取列表
-        getSimpleList();
     } else {
         // 重置为初始位置
         mapPoint.value = store.state.home.miniUserLocationPoint;
         indexMap.clickPointLayer.source.clear();
         // 更新区县列表
         getDistrictListByCity();
-        // 重新获取列表
-        getSimpleList();
         getStatisticsAreaByDistrict();
     }
 }

+ 18 - 4
src/views/old_mini/mine/pages/register.vue

@@ -144,7 +144,7 @@
 <script setup>
 import customHeader from "@/components/customHeader.vue";
 import { Field, Form, Button } from "vant";
-import { onActivated, ref } from "vue";
+import { onActivated, onDeactivated, ref } from "vue";
 import { useRoute, useRouter } from "vue-router";
 import { ElMessage } from "element-plus";
 import upload from "@/components/upload";
@@ -204,7 +204,7 @@ const handleYearDropdown = (item, index) => {
     yearActive.value = index;
 };
 
-const dropdownList = ["周边20公里", "飞防类", "技术类", "劳力类", "机械类"];
+const dropdownList = ["周边20公里", "周边10公里", "周边5公里"];
 const active = ref(0);
 const dropdownName = ref("周边20公里");
 const handleDropdown = (item, index) => {
@@ -225,8 +225,9 @@ const identityTyepe = {
 // 服务信息数据,转换为 ServiceInfo 组件需要的格式
 const isEdit = ref(true); // 默认编辑状态
 const crops = ref([
-    { name: "荔枝", isSelf: 0 },
-    { name: "龙眼", isSelf: 1 }
+    { name: "荔枝", isSelf: 1 },
+    { name: "龙眼", isSelf: 0 },
+    { name: "芒果", isSelf: 0 }
 ]);
 const serviceTypes = ref([
     { name: "播种", isSelf: 1 },
@@ -248,6 +249,19 @@ onActivated(() => {
     formData.value = {};
     resetForm();
 });
+
+onDeactivated(() => {
+    // 重置 ServiceInfo 组件的选中状态
+    crops.value.forEach(item => {
+        item.selected = false;
+    });
+    serviceTypes.value.forEach(item => {
+        item.selected = false;
+    });
+    machines.value.forEach(item => {
+        item.selected = false;
+    });
+});
 </script>
 
 <style lang="scss" scoped>

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

@@ -15,7 +15,7 @@
                         @change="handleTabChange"
                         class="tabs-list"
                     />
-                    <plan-list :schemeId="active" :containerId="containerId" :isEdit="isEditVal"> </plan-list>
+                    <plan-list :schemeId="active" :farmId="route.query.farmId" :containerId="containerId" :isEdit="isEditVal"> </plan-list>
                 </div>
             </Tab>
         </Tabs>

+ 165 - 130
src/views/old_mini/task_condition/components/task.vue

@@ -22,26 +22,37 @@
                 </div>
             </div>
             <div class="select-group">
-                <el-select class="select-item" v-model="dateValue" placeholder="Select">
-                    <el-option v-for="item in dateOptions" :key="item.value" :label="item.label" :value="item.value" />
+                <el-select
+                    class="select-item"
+                    v-model="selectParma.farmWorkTypeId"
+                    placeholder="农事类型"
+                    @change="getSimpleList"
+                >
+                    <el-option v-for="item in farmWorkTypeList" :key="item.id" :label="item.name" :value="item.id" />
                 </el-select>
-                <el-select class="select-item" v-model="areaValue" placeholder="Select">
-                    <el-option v-for="item in areaOptions" :key="item.value" :label="item.label" :value="item.value" />
-                </el-select>
-                <el-select class="select-item" v-model="areaValue1" placeholder="Select">
-                    <el-option v-for="item in areaOptions1" :key="item.value" :label="item.label" :value="item.value" />
+                <el-select
+                    class="select-item"
+                    v-model="selectParma.districtCode"
+                    placeholder="区域筛选"
+                    @change="getSimpleList"
+                >
+                    <el-option v-for="item in districtList" :key="item.code" :label="item.name" :value="item.code" />
                 </el-select>
             </div>
             <!-- <div class="task-content-loading" v-if="loading && noData" v-loading="loading">
             </div> -->
             <div class="task-content" v-loading="loading">
                 <div class="task-item" v-for="(item, index) in taskList" :key="item.id || item.workRecordId">
-                    <task-item :key="activeIndex + '-' + index" :status="activeIndex === 3 ? 1 : 0" :item-data="item" @handleUploadSuccess="handleUploadSuccess" :ref="el => setTaskItemRef(el, index)">
+                    <task-item
+                        :key="activeIndex + '-' + index"
+                        :status="activeIndex === 3 ? 1 : 0"
+                        :item-data="item"
+                        @handleUploadSuccess="handleUploadSuccess"
+                        :ref="(el) => setTaskItemRef(el, index)"
+                    >
                         <template #footer>
                             <div class="item-footer" v-if="activeIndex === 0 || activeIndex === 2">
-                                <div class="footer-l" @click="toDetail(item)">
-                                    查看详情
-                                </div>
+                                <div class="footer-l" @click="toDetail(item)">查看详情</div>
                                 <div class="footer-r">
                                     <div v-if="activeIndex === 0" class="btn second" @click="handleAction(item)">
                                         忽略
@@ -52,16 +63,12 @@
                                 </div>
                             </div>
                             <div v-else-if="activeIndex === 1" class="item-footer">
-                                <div class="footer-l" @click="toDetail(item)">
-                                    查看详情
-                                </div>
+                                <div class="footer-l" @click="toDetail(item)">查看详情</div>
                                 <div class="footer-r">
                                     <!-- <div class="btn second" @click="handleForward(item)">
                                         转发给客户
                                     </div> -->
-                                    <div class="btn primary" @click="showPriceSheetPopup(item)">
-                                        生成报价单
-                                    </div>
+                                    <div class="btn primary" @click="showPriceSheetPopup(item)">生成报价单</div>
                                 </div>
                             </div>
                         </template>
@@ -75,20 +82,24 @@
 
     <popup v-model:show="showTaskPopup" round class="task-tips-popup">
         <template v-if="taskPopupType === 'warning'">
-            <img  class="create-farm-icon" src="@/assets/img/home/create-farm-icon.png" alt="" />
+            <img class="create-farm-icon" src="@/assets/img/home/create-farm-icon.png" alt="" />
             <div class="create-farm-text">
-                <div>您确认忽略 <span class="main-text">{{ currentTask?.farmName }}</span> 的 <span class="main-text">{{ currentTask?.farmWorkName }}</span> 农事吗</div>
+                <div>
+                    您确认忽略 <span class="main-text">{{ currentTask?.farmName }}</span> 的
+                    <span class="main-text">{{ currentTask?.farmWorkName }}</span> 农事吗
+                </div>
             </div>
         </template>
         <template v-else>
-            <img class="farm-check-icon" src="@/assets/img/home/right.png" alt="">
+            <img class="farm-check-icon" src="@/assets/img/home/right.png" alt="" />
             <div class="create-farm-text success-text">农事已下发成功</div>
         </template>
-        <div class="create-farm-btn" @click="handlePopupBtn">{{ taskPopupType === 'warning' ? '确认忽略' : '我知道了' }}</div>
+        <div class="create-farm-btn" @click="handlePopupBtn">
+            {{ taskPopupType === "warning" ? "确认忽略" : "我知道了" }}
+        </div>
     </popup>
     <!-- 服务报价单 -->
     <price-sheet-popup ref="priceSheetPopupRef"></price-sheet-popup>
-
 </template>
 
 <script setup>
@@ -97,7 +108,7 @@ import { useStore } from "vuex";
 import { Popup } from "vant";
 import IndexMap from "../../farm_manage/map/index";
 import taskItem from "@/components/taskItem.vue";
-import calendar from "./calendar.vue"
+import calendar from "./calendar.vue";
 import { useRouter } from "vue-router";
 import uploadExecute from "./uploadExecute.vue";
 import priceSheetPopup from "@/components/popup/priceSheetPopup.vue";
@@ -111,23 +122,11 @@ const tabBarHeight = computed(() => store.state.home.tabBarHeight);
 const uploadExecuteRef = ref(null);
 const dateValue = ref("1");
 const calendarRef = ref(null);
-const dateOptions = [
-    { value: "1", label: "农事类型" },
-    { value: "2", label: "2" },
-    { value: "3", label: "3" },
-];
-const areaValue = ref("1");
-const areaOptions = [
-    { value: "1", label: "距离" },
-    { value: "2", label: "2" },
-    { value: "3", label: "3" },
-];
-const areaValue1 = ref("1");
-const areaOptions1 = [
-    { value: "1", label: "区域筛选" },
-    { value: "2", label: "2" },
-    { value: "3", label: "3" },
-];
+
+const selectParma = ref({
+    farmWorkTypeId: null,
+    districtCode: null,
+});
 
 // 任务列表数据
 const taskList = ref([]);
@@ -139,15 +138,15 @@ const noData = ref(false);
 const loading = ref(false);
 
 const showTaskPopup = ref(false);
-const taskPopupType = ref('warning');
+const taskPopupType = ref("warning");
 
 // 根据 activeIndex 计算 startFlowStatus
 const getStartFlowStatus = (index) => {
     const statusMap = {
         0: 0, // 待确认
-        1: '1,2,3', // 待完成
+        1: "1,2,3", // 待完成
         2: 4, // 待完成
-        3: 5  // 已完成
+        3: 5, // 已完成
     };
     return statusMap[index] ?? 0;
 };
@@ -155,24 +154,27 @@ const getStartFlowStatus = (index) => {
 // 获取单个状态的任务数量
 function getTaskCount(flowStatus, index) {
     const location = store.state.home.miniUserLocationPoint;
-    return VE_API.z_farm_work_record.getSimpleList({ role: 2, location, flowStatus }).then(({data}) => {
-        if (Array.isArray(data)) {
-            taskCounts.value[index] = data.length;
-            calendarRef.value && calendarRef.value.setCounts(index, taskCounts.value[index])
-            
-            if (index === 2) {
-                calendarRef.value && calendarRef.value.setSolarTerm(data)
-                indexMap.initData(data)
+    return VE_API.z_farm_work_record
+        .getSimpleList({ role: 2, location, flowStatus })
+        .then(({ data }) => {
+            if (Array.isArray(data)) {
+                taskCounts.value[index] = data.length;
+                calendarRef.value && calendarRef.value.setCounts(index, taskCounts.value[index]);
+
+                if (index === 2) {
+                    calendarRef.value && calendarRef.value.setSolarTerm(data);
+                    indexMap.initData(data);
+                }
+            } else if (data?.total !== undefined) {
+                taskCounts.value[index] = data.total;
+            } else {
+                taskCounts.value[index] = 0;
             }
-        } else if (data?.total !== undefined) {
-            taskCounts.value[index] = data.total;
-        } else {
+        })
+        .catch((error) => {
+            console.error(`获取状态${index}任务数量失败:`, error);
             taskCounts.value[index] = 0;
-        }
-    }).catch((error) => {
-        console.error(`获取状态${index}任务数量失败:`, error);
-        taskCounts.value[index] = 0;
-    });
+        });
 }
 
 const taskItemRefs = ref([]);
@@ -182,22 +184,43 @@ const setTaskItemRef = (el, index) => {
     }
 };
 
-const handleUploadSuccess = async () =>{
+const handleUploadSuccess = async () => {
     // 先保存当前需要更新的 item id
-    const currentItemIds = taskList.value.map(item => item.id || item.workRecordId);
-    
+    const currentItemIds = taskList.value.map((item) => item.id || item.workRecordId);
+
     // 刷新列表
     await getSimpleList();
-    
+
     // 等待 DOM 更新完成,refs 被重新收集
     await nextTick();
-    
+
     // 更新所有task-item的triggerImg
-    taskItemRefs.value.forEach(ref => {
+    taskItemRefs.value.forEach((ref) => {
         if (ref && ref.updateTriggerImg) {
             ref.updateTriggerImg();
         }
     });
+};
+
+//根据城市的坐标返回区县列表
+const districtList = ref([]);
+function getDistrictListByCity() {
+    VE_API.z_farm_work_record.getDistrictListByCity({ point: mapPoint.value }).then(({ data }) => {
+        districtList.value = data || [];
+        const cityCode = data[0].code.slice(0, -2);
+        districtList.value.unshift({ code: cityCode, name: "全部" });
+        selectParma.value.districtCode = cityCode;
+        getSimpleList()
+    });
+}
+
+//农事类型列表
+const farmWorkTypeList = ref([]);
+function getFarmWorkTypeList() {
+    VE_API.z_farm_work_record.getFarmWorkTypeList().then(({ data }) => {
+        farmWorkTypeList.value = data;
+        farmWorkTypeList.value.unshift({ id: 0, name: "全部" });
+    });
 }
 
 // 初始化时获取所有状态的任务数量
@@ -205,21 +228,25 @@ function initTaskCounts() {
     const location = store.state.home.miniUserLocationPoint;
     // 并行请求三个状态的数量
     Promise.all([
-        getTaskCount(0, 0),  // 待确认
-        getTaskCount('1,2,3', 1),  // 待确认
-        getTaskCount(4, 2),  // 待完成
-        getTaskCount(5, 3)   // 已完成
+        getTaskCount(0, 0), // 待确认
+        getTaskCount("1,2,3", 1), // 待确认
+        getTaskCount(4, 2), // 待完成
+        getTaskCount(5, 3), // 已完成
     ]);
 }
+const mapPoint = ref(null);
 
 onMounted(() => {
+    mapPoint.value = store.state.home.miniUserLocationPoint;
+
     // 初始化时获取所有状态的数量
     initTaskCounts();
     // 加载当前选中状态的数据列表
     getSimpleList();
-    const point = store.state.home.miniUserLocationPoint;
+    getDistrictListByCity();
+    getFarmWorkTypeList();
     nextTick(() => {
-        indexMap.initMap(point, mapContainer.value, true);
+        indexMap.initMap(mapPoint.value, mapContainer.value, true);
     });
 });
 
@@ -233,34 +260,42 @@ function getSimpleList() {
     noData.value = false;
     // 清空refs数组,避免索引错乱
     taskItemRefs.value = [];
-    const location = store.state.home.miniUserLocationPoint;
     const startFlowStatus = getStartFlowStatus(activeIndex.value);
-    return VE_API.z_farm_work_record.getSimpleList({ role: 2, location, flowStatus: startFlowStatus }).then(({data}) => {
-        loading.value = false;
-        // 假设返回的数据结构是 { list: [], total: 0 } 或者直接是数组
-        if (Array.isArray(data) && data.length > 0) {
-            taskList.value = data;
-            // 更新当前状态的数量
-            taskCounts.value[activeIndex.value] = data.length;
-            if (activeIndex.value === 2) {
-                calendarRef.value && calendarRef.value.setSolarTerm(taskList.value)
-                indexMap.initData(taskList.value)
+    const params = {
+        role: 2,
+        location: mapPoint.value,
+        flowStatus: startFlowStatus,
+        farmWorkTypeId: selectParma.value.farmWorkTypeId || null,
+    };
+    return VE_API.z_farm_work_record
+        .getSimpleList(params)
+        .then(({ data }) => {
+            loading.value = false;
+            // 假设返回的数据结构是 { list: [], total: 0 } 或者直接是数组
+            if (Array.isArray(data) && data.length > 0) {
+                taskList.value = data;
+                // 更新当前状态的数量
+                taskCounts.value[activeIndex.value] = data.length;
+                if (activeIndex.value === 2) {
+                    calendarRef.value && calendarRef.value.setSolarTerm(taskList.value);
+                    indexMap.initData(taskList.value);
+                }
+            } else {
+                taskList.value = [];
+                taskCounts.value[activeIndex.value] = 0;
+                if (activeIndex.value === 2) {
+                    indexMap.initData(taskList.value);
+                    calendarRef.value && calendarRef.value.setSolarTerm(taskList.value);
+                }
+                noData.value = true;
             }
-        } else {
+        })
+        .catch((error) => {
+            console.error("获取任务列表失败:", error);
+            loading.value = false;
             taskList.value = [];
-            taskCounts.value[activeIndex.value] = 0;
-            if (activeIndex.value === 2) {
-                indexMap.initData(taskList.value)
-                calendarRef.value && calendarRef.value.setSolarTerm(taskList.value)
-            }
             noData.value = true;
-        }
-    }).catch((error) => {
-        console.error('获取任务列表失败:', error);
-        loading.value = false;
-        taskList.value = [];
-        noData.value = true;
-    });
+        });
 }
 
 function handleActiveFilter(i) {
@@ -276,9 +311,8 @@ function toPage(item) {
             onlyShare.value = false;
         }
         setTimeout(() => {
-            uploadExecuteRef.value.showPopup({...item, type: 'confirmExecute'},'share-sheet');
+            uploadExecuteRef.value.showPopup({ ...item, type: "confirmExecute" }, "share-sheet");
         }, 10);
-       
     } else {
         // 下发农事请求
         const data = {
@@ -286,11 +320,11 @@ function toPage(item) {
         };
         VE_API.z_farm_work_record.issueFarmWorkRecord(data).then((res) => {
             if (res.code === 0) {
-                taskPopupType.value = 'success';
+                taskPopupType.value = "success";
                 showTaskPopup.value = true;
-                getSimpleList()
+                getSimpleList();
             }
-        })
+        });
         // router.push("/service_agri");
     }
 }
@@ -299,12 +333,12 @@ function toDetail(item) {
     if (activeIndex.value === 0) {
         router.push({
             path: "/modify_work",
-            query: { id: item.id }
+            query: { id: item.id },
         });
     } else {
         router.push({
             path: "/completed_work",
-            query: { json: JSON.stringify({ id: item.id }) }
+            query: { json: JSON.stringify({ id: item.id }) },
         });
     }
 }
@@ -321,24 +355,24 @@ const onlyShare = ref(false);
 const currentTask = ref(null);
 function handleAction(item) {
     if (activeIndex.value === 0) {
-        taskPopupType.value = 'warning';
+        taskPopupType.value = "warning";
         showTaskPopup.value = true;
         currentTask.value = item;
-    }else{
+    } else {
         onlyShare.value = true;
         setTimeout(() => {
-            uploadExecuteRef.value.showPopup(item,'share-sheet');
+            uploadExecuteRef.value.showPopup(item, "share-sheet");
         }, 10);
     }
 }
 
 function handlePopupBtn() {
     showTaskPopup.value = false;
-    if (taskPopupType.value === 'warning') {
+    if (taskPopupType.value === "warning") {
         // 确认忽略
     } else {
         // 待确认
-        getTaskCount('1,2,3', 1)
+        getTaskCount("1,2,3", 1);
     }
 }
 
@@ -346,14 +380,16 @@ function handleForward(item) {
     if (item.quoteCount && item.quoteCount != 0) {
         onlyShare.value = true;
         setTimeout(() => {
-            uploadExecuteRef.value.showPopup({...item, type:'quotation', farmWorkOrderId:item.orderId},'share-sheet');
+            uploadExecuteRef.value.showPopup(
+                { ...item, type: "quotation", farmWorkOrderId: item.orderId },
+                "share-sheet"
+            );
         }, 10);
     } else {
-        ElMessage.warning('暂无报价数据,无法分享')
+        ElMessage.warning("暂无报价数据,无法分享");
         return;
     }
 }
-
 </script>
 
 <style lang="scss" scoped>
@@ -423,7 +459,7 @@ function handleForward(item) {
     .empty-data {
         text-align: center;
         font-size: 14px;
-        color: #6F7274;
+        color: #6f7274;
         padding: 20px 0;
     }
     .task-list {
@@ -452,7 +488,7 @@ function handleForward(item) {
     .task-item + .task-item {
         margin-top: 10px;
     }
-    
+
     .item-footer {
         margin-top: 10px;
         padding-top: 11px;
@@ -462,12 +498,12 @@ function handleForward(item) {
         justify-content: space-between;
         font-size: 12px;
         .footer-l {
-            color: #8B8B8B;
+            color: #8b8b8b;
             font-size: 12px;
             &.primary-btn {
                 display: inline-flex;
                 align-items: center;
-                border: 1px solid #2199F8;
+                border: 1px solid #2199f8;
                 background: rgba(33, 153, 248, 0.1);
                 padding: 0 12px;
                 height: 32px;
@@ -475,7 +511,7 @@ function handleForward(item) {
                 display: flex;
                 align-items: center;
                 border-radius: 20px;
-                color: #2199F8;
+                color: #2199f8;
                 .share-icon {
                     width: 12px;
                     padding-right: 4px;
@@ -483,7 +519,7 @@ function handleForward(item) {
             }
             &.farm-name-text {
                 font-size: 14px;
-                color: #6F7274;
+                color: #6f7274;
                 .name-text {
                     padding-left: 4px;
                 }
@@ -503,24 +539,24 @@ function handleForward(item) {
                 &.second {
                     // border: 1px solid #8B8B8B;
                     // color: #8B8B8B;
-                    color: #2199F8;
+                    color: #2199f8;
                     background: rgba(33, 153, 248, 0.1);
                 }
                 &.primary {
-                    background: #2199F8;
+                    background: #2199f8;
                     color: #fff;
                 }
                 .btn-icon {
                     padding-right: 4px;
                 }
                 &.warning {
-                    color: #FF953D;
+                    color: #ff953d;
                     background: #fff;
-                    border: 1px solid #FF953D;
+                    border: 1px solid #ff953d;
                 }
                 &.secondary-text {
-                    color: #2199F8;
-                    border: 1px solid #2199F8;
+                    color: #2199f8;
+                    border: 1px solid #2199f8;
                 }
             }
             .btn + .btn {
@@ -530,7 +566,6 @@ function handleForward(item) {
     }
 }
 
-
 .task-tips-popup {
     width: 75%;
     padding: 28px 28px 20px;
@@ -538,37 +573,37 @@ function handleForward(item) {
     flex-direction: column;
     align-items: center;
     justify-content: center;
-    .create-farm-icon{
+    .create-farm-icon {
         width: 40px;
         height: 40px;
         margin-bottom: 12px;
     }
-    .farm-check-icon{
+    .farm-check-icon {
         width: 68px;
         height: 68px;
         margin-bottom: 12px;
     }
-    .create-farm-text{
+    .create-farm-text {
         font-size: 20px;
         font-weight: 500;
         line-height: 40px;
         margin-bottom: 32px;
         text-align: center;
-        &.success-text{
+        &.success-text {
             font-size: 23px;
             font-weight: 400;
         }
     }
     .main-text {
-        color: #2199F8;
+        color: #2199f8;
     }
-    .create-farm-btn{
+    .create-farm-btn {
         width: 100%;
         box-sizing: border-box;
         padding: 8px;
         border-radius: 25px;
         font-size: 16px;
-        background: #2199F8;
+        background: #2199f8;
         color: #fff;
         text-align: center;
     }