Sfoglia il codice sorgente

feat:修改时间轴组件

wangsisi 13 ore fa
parent
commit
0707824693

+ 76 - 12
src/components/pageComponents/AgriculturalInteractionCard.vue

@@ -10,27 +10,31 @@
                 <div class="date">
                     <span class="work-name">{{ timelineItem.farmWorkName }}</span>
                     <span v-show="timelineItem.expectedRisk">({{ timelineItem.expectedRisk }})</span>
-                    <span class="ignore-btn" @click="$emit('ignore', { timelineItem, farmId: item.farmId })">
+                    <span class="ignore-btn" @click="handleIgnore(timelineItem, item.farmId)">
                         忽略
                     </span>
                 </div>
                 <div class="text">
                     预计报价<span class="price">{{ timelineItem.estimatedCost }}元</span>
-                    <span class="action-detail" @click="$emit('show-price-sheet', timelineItem)">查看报价单</span>
+                    <span class="action-detail" @click="showPriceSheetPopup(timelineItem)">查看报价单</span>
                 </div>
             </div>
-            <div
-                v-has-permission="'转入农事'"
-                class="timeline-action"
-                @click="$emit('timeline-action', { timelineItem, farmId: item.farmId })"
-            >
-                转入农事任务
-            </div>
+            <div class="timeline-action" @click="handleTimelineAction(timelineItem, item.farmId)">转入农事任务</div>
         </div>
     </div>
+    <!-- 新增:激活上传弹窗 -->
+    <active-upload-popup ref="activeUploadPopupRef" @handleUploadSuccess="handleUploadSuccess"></active-upload-popup>
+
+    <!-- 服务报价单 -->
+    <price-sheet-popup ref="priceSheetPopupRef"></price-sheet-popup>
 </template>
 
 <script setup>
+import activeUploadPopup from "@/components/popup/activeUploadPopup.vue";
+import priceSheetPopup from "@/components/popup/priceSheetPopup.vue";
+import { computed, onMounted, ref } from "vue";
+import { ElMessage } from "element-plus";
+
 const props = defineProps({
     item: {
         type: Object,
@@ -39,7 +43,69 @@ const props = defineProps({
     },
 });
 
-defineEmits(["timeline-action", "show-price-sheet", "ignore"]);
+// 检查是否有"转入农事"权限
+const hasPlanPermission = computed(() => {
+    try {
+        const userInfoStr = localStorage.getItem("localUserInfo");
+        if (!userInfoStr) return false;
+        const userInfo = JSON.parse(userInfoStr);
+        const permissions = userInfo.agriculturalPermissions || [];
+        return permissions.includes("转入农事");
+    } catch (error) {
+        console.error("解析用户信息失败:", error);
+        return false;
+    }
+});
+
+onMounted(() => {
+    getManagerList();
+});
+
+
+// 查询当前农资店的成员列表(只保留有“任务接单”权限的成员)
+const getManagerList = async () => {
+    const { data } = await VE_API.mine.listManagerList({onlyExecutor: true});
+    if (data && data.length > 0) {
+        // 过滤 permissionList 中包含“任务接单”的成员
+        executorList.value = data;
+    }
+};
+
+const executorList = ref([]);
+const activeUploadPopupRef = ref(null);
+const handleTimelineAction = (timelineItem, farmId) => {
+    if (hasPlanPermission.value) {
+        activeUploadPopupRef.value.showPopup({
+            gardenIdVal: farmId,
+            needExecutorVal: true,
+            problemTitleVal: "请选择 " + timelineItem.farmWorkName + " 执行截止时间",
+            imgDescVal: "请上传凭证(转入农事任务凭证)",
+            arrangeIdVal: timelineItem.arrangeId,
+            executorListVal: executorList.value,
+        });
+    }else{
+        ElMessage.warning("您暂无权限操作");
+    }
+};
+
+const handleUploadSuccess = async () => {
+    emit('handleUploadSuccess');
+};
+
+const handleIgnore = (timelineItem, farmId) => {
+    console.log('timelineItem', timelineItem);
+    console.log('farmId', 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 emit = defineEmits(["handleUploadSuccess"]);
 </script>
 
 <style scoped lang="scss">
@@ -117,5 +183,3 @@ defineEmits(["timeline-action", "show-price-sheet", "ignore"]);
     }
 }
 </style>
-
-

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

@@ -41,31 +41,18 @@
                     ></div>
 
                     <!-- 时间轴组件,只负责时间轴区域 -->
-                    <AgriculturalInteractionCard
-                        :item="item"
-                        @timeline-action="({ timelineItem, farmId }) => handleTimelineAction(timelineItem, farmId)"
-                        @show-price-sheet="showPriceSheetPopup"
-                        @ignore="handleIgnore"
-                    />
+                    <AgriculturalInteractionCard :item="item" @handleUploadSuccess="getUnansweredFarms" />
                 </div>
             </template>
         </div>
     </div>
     <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>
 import router from "@/router";
 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";
 import AgriculturalInteractionCard from "@/components/pageComponents/AgriculturalInteractionCard.vue";
 // 任务列表数据
 const taskList = ref([
@@ -102,48 +89,12 @@ const handleTaskAction = (item) => {
     offerPopupRef.value.openPopup(data);
 };
 
-// 查询当前农资店的成员列表(只保留有“任务接单”权限的成员)
-const getManagerList = async () => {
-    const { data } = await VE_API.mine.listManagerList({onlyExecutor: true});
-    if (data && data.length > 0) {
-        // 过滤 permissionList 中包含“任务接单”的成员
-        executorList.value = data;
-    }
-};
-
-const executorList = ref([]);
-const handleTimelineAction = (item, farmId) => {
-    // 处理转入农事任务逻辑
-    eventBus.emit("activeUpload:show", {
-        gardenIdVal: farmId,
-        needExecutorVal: true,
-        problemTitleVal: "请选择 " + item.farmWorkName + " 执行截止时间",
-        imgDescVal: "请上传凭证(转入农事任务凭证)",
-        arrangeIdVal: item.arrangeId,
-        executorListVal: executorList.value,
-    });
-};
-
-
-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();
-};
-
 const handleRemind = (item) => {
     router.push(`/remind_customer?farmId=${item.farmId}`);
 };
 
 onMounted(() => {
     getUnansweredFarms();
-    getManagerList();
 });
 
 //农情互动的农场列表接口(分页)

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

@@ -382,7 +382,7 @@ const handleDeleteInteract = (params) => {
             }
             // 没有权限时,底部按钮不显示,高度增加 73px
             &.timeline-container-no-permission {
-                height: calc(100vh - 40px - 58px);
+                height: calc(100vh - 40px - 18px);
             }
         }
     }

+ 5 - 2
src/views/old_mini/plan/index.vue

@@ -72,7 +72,7 @@ const getListMySchemes = () => {
         if (data.length) {
             tabs.value = data || [];
             const index = data.findIndex((item) => item.containerId == route.query.containerId);
-            active.value = data[index].id;
+            active.value = route.query.schemeId || data[index].id;
             containerId.value = route.query.containerId;
         }
     });
@@ -101,6 +101,7 @@ const handleConfirmPlan = () => {
     const farmParams = {
         ...route.query,
         containerId: containerId.value,
+        schemeId: active.value,
         geom: geomValue,
         defaultFarm: Boolean(route.query.defaultFarm),
         agriculturalCreate: route.query.agriculturalCreate * 1,
@@ -129,7 +130,9 @@ const handleConfirmPlan = () => {
             if (res.code === 0) {
                 shareData.value = res.data;
                 ElMessage.success("创建成功");
-                handleClickOverlay();
+                setTimeout(() => {
+                    handleClickOverlay();
+                }, 1000);
             } else {
                 ElMessage.error(res.msg || "创建失败");
             }