ソースを参照

feat:修改新增客户逻辑和农事规划显示逻辑

wangsisi 1 週間 前
コミット
3153c6c9dd

+ 587 - 0
src/components/pageComponents/FarmWorkPlanTimeline copy.vue

@@ -0,0 +1,587 @@
+<template>
+    <div
+        class="timeline-container"
+        ref="timelineContainerRef"
+        :class="{ 'timeline-container-plant': pageType === 'plant' }"
+    >
+        <div class="timeline-list" :style="getListStyle">
+            <div class="timeline-middle-line"></div>
+            <!-- 物候期覆盖条(progress 为起点,progress2 为终点,单位 %) -->
+            <div
+                v-for="(p, idx) in phenologyList"
+                :key="p.id ?? idx"
+                class="phenology-bar"
+                :style="getPhenologyBarStyle(p)"
+            >
+                <div class="reproductive-list">
+                    <div
+                        v-for="(r, rIdx) in Array.isArray(p.reproductiveList) ? p.reproductiveList : []"
+                        :key="r.id ?? rIdx"
+                        class="reproductive-item"
+                        :class="{
+                            'horizontal-text': getReproductiveItemHeight(p) < 30,
+                            'vertical-lr-text': getReproductiveItemHeight(p) >= 30,
+                        }"
+                        :style="
+                            getReproductiveItemHeight(p) < 30
+                                ? { '--item-height': `${getReproductiveItemHeight(p)}px` }
+                                : {}
+                        "
+                    >
+                        {{ r.name }}
+                        <div class="arranges">
+                            <div
+                                v-for="(fw, aIdx) in Array.isArray(r.farmWorkArrangeList) ? r.farmWorkArrangeList : []"
+                                :key="fw.id ?? aIdx"
+                                class="arrange-card"
+                                :class="getArrangeStatusClass(fw)"
+                                @click="handleRowClick(fw)"
+                            >
+                                <div class="card-header">
+                                    <div class="header-left">
+                                        <span class="farm-work-name">{{ fw.farmWorkName || "农事名称" }}</span>
+                                        <span class="tag-standard">标准农事</span>
+                                    </div>
+                                    <div class="header-right">
+                                        {{ fw.isFollow == 1 ? "已关注" : fw.isFollow == 2 ? "托管农事" : "" }}
+                                    </div>
+                                </div>
+                                <div class="card-content">
+                                    <span>{{ fw.interactionQuestion || "暂无提示" }}</span>
+                                    <span v-if="!disableClick" class="edit-link" @click.stop="handleEdit(fw)"
+                                        >点击编辑</span
+                                    >
+                                </div>
+                                <div
+                                    v-if="
+                                        getArrangeStatusClass(fw) === 'status-complete' ||
+                                        getArrangeStatusClass(fw) === 'status-warning'
+                                    "
+                                    class="status-icon"
+                                    :class="getArrangeStatusClass(fw)"
+                                >
+                                    <el-icon
+                                        v-if="getArrangeStatusClass(fw) === 'status-complete'"
+                                        size="16"
+                                        color="#1CA900"
+                                    >
+                                        <SuccessFilled />
+                                    </el-icon>
+                                    <el-icon v-else size="18" color="#FF953D">
+                                        <WarnTriangleFilled />
+                                    </el-icon>
+                                </div>
+                            </div>
+                        </div>
+                    </div>
+                </div>
+            </div>
+            <div v-for="t in solarTerms" :key="t.id" class="timeline-term" :style="getTermStyle(t)">
+                <span class="term-name">{{ t.displayName }}</span>
+            </div>
+        </div>
+    </div>
+    <!-- 互动设置弹窗 -->
+    <interact-popup ref="interactPopupRef" @handleSaveSuccess="getFarmWorkPlan"></interact-popup>
+</template>
+
+<script setup>
+import { ref, computed, nextTick, watch } from "vue";
+import interactPopup from "@/components/popup/interactPopup.vue";
+import { ElMessage } from "element-plus";
+
+const props = defineProps({
+    // 农场 ID,用于请求农事规划数据
+    farmId: {
+        type: [String, Number],
+        default: null,
+    },
+    // 页面类型:种植方案 / 农事规划,用来控制高度样式
+    pageType: {
+        type: String,
+        default: "",
+    },
+    // 是否禁用所有点击事件(用于只读展示)
+    disableClick: {
+        type: Boolean,
+        default: false,
+    },
+    containerId: {
+        type: [Number, String],
+        default: null,
+    },
+});
+
+const emits = defineEmits(["row-click"]);
+
+const solarTerms = ref([]);
+const phenologyList = ref([]);
+const timelineContainerRef = ref(null);
+// 标记是否为首次加载
+const isInitialLoad = ref(true);
+
+// 获取当前季节
+const getCurrentSeason = () => {
+    const month = new Date().getMonth() + 1; // 1-12
+    if (month >= 3 && month <= 5) {
+        return "spring"; // 春季:3-5月
+    } else if (month >= 6 && month <= 8) {
+        return "summer"; // 夏季:6-8月
+    } else if (month >= 9 && month <= 10) {
+        return "autumn"; // 秋季:9-10月
+    } else {
+        return "winter"; // 冬季:11-2月
+    }
+};
+
+// 安全解析时间到时间戳(ms)
+const safeParseDate = (val) => {
+    if (!val) return NaN;
+    if (val instanceof Date) return val.getTime();
+    if (typeof val === "number") return val;
+    if (typeof val === "string") {
+        // 兼容 "YYYY-MM-DD HH:mm:ss" -> Safari
+        const s = val.replace(/-/g, "/").replace("T", " ");
+        const d = new Date(s);
+        return isNaN(d.getTime()) ? NaN : d.getTime();
+    }
+    return NaN;
+};
+
+// 计算最小progress值(第一个节气的progress)
+const minProgress = computed(() => {
+    if (!solarTerms.value || solarTerms.value.length === 0) return 0;
+    const progresses = solarTerms.value.map((t) => Number(t?.progress) || 0).filter((p) => !isNaN(p));
+    return progresses.length > 0 ? Math.min(...progresses) : 0;
+});
+
+// 计算最大progress值
+const maxProgress = computed(() => {
+    if (!solarTerms.value || solarTerms.value.length === 0) return 100;
+    const progresses = solarTerms.value.map((t) => Number(t?.progress) || 0).filter((p) => !isNaN(p));
+    return progresses.length > 0 ? Math.max(...progresses) : 100;
+});
+
+// 列表高度
+const getListStyle = computed(() => {
+    const minP = minProgress.value;
+    const maxP = maxProgress.value;
+    const range = Math.max(1, maxP - minP); // 避免除0
+    const total = (solarTerms.value?.length || 0) * 1200;
+    const minH = range === 0 ? 0 : total;
+    return { minHeight: `${minH}px` };
+});
+
+const getTermStyle = (t) => {
+    const p = Math.max(0, Math.min(100, Number(t?.progress) || 0));
+    const minP = minProgress.value;
+    const maxP = maxProgress.value;
+    const range = Math.max(1, maxP - minP); // 避免除0
+    const total = (solarTerms.value?.length || 0) * 1200;
+    // 将progress映射到0开始的位置,最小progress对应top: 0
+    const normalizedP = range > 0 ? ((p - minP) / range) * 100 : 0;
+    const top = (normalizedP / 100) * total;
+    return {
+        position: "absolute",
+        top: `${top}px`,
+        left: 0,
+        width: "30px",
+        height: "20px",
+        display: "flex",
+        alignItems: "flex-start",
+    };
+};
+
+// 点击季节 → 滚动到对应节气(立春/立夏/立秋/立冬)
+const handleSeasonClick = (seasonValue) => {
+    const mapping = {
+        spring: "立春",
+        summer: "立夏",
+        autumn: "立秋",
+        winter: "立冬",
+    };
+    const targetName = mapping[seasonValue];
+    if (!targetName) return;
+    const target = (solarTerms.value || []).find((t) => (t?.displayName || "") === targetName);
+    if (!target) return;
+    const p = Math.max(0, Math.min(100, Number(target.progress) || 0));
+    const minP = minProgress.value;
+    const maxP = maxProgress.value;
+    const range = Math.max(1, maxP - minP);
+    const total = (solarTerms.value?.length || 0) * 1200;
+    const normalizedP = range > 0 ? ((p - minP) / range) * 100 : 0;
+    const targetTop = (normalizedP / 100) * total; // 内容内的像素位置
+    const wrap = timelineContainerRef.value;
+    if (!wrap) return;
+    const viewH = wrap.clientHeight || 0;
+    const maxScroll = Math.max(0, wrap.scrollHeight - viewH);
+    // 将目标位置稍微靠上(使用 0.35 视口高度做偏移)
+    let scrollTop = Math.max(0, targetTop - viewH * 0.1);
+    if (scrollTop > maxScroll) scrollTop = maxScroll;
+    wrap.scrollTo({ top: scrollTop, behavior: "smooth" });
+};
+
+// 物候期覆盖条样式
+const getPhenologyBarStyle = (item) => {
+    const p1 = Math.max(0, Math.min(100, Number(item?.progress) || 0));
+    const p2 = Math.max(0, Math.min(100, Number(item?.progress2) || 0));
+    const start = Math.min(p1, p2);
+    const end = Math.max(p1, p2);
+    const minP = minProgress.value;
+    const maxP = maxProgress.value;
+    const range = Math.max(1, maxP - minP);
+    const total = (solarTerms.value?.length || 0) * 1200; // 有效绘制区高度(px)
+    // 将progress映射到0开始的位置
+    const normalizedStart = range > 0 ? ((start - minP) / range) * 100 : 0;
+    const normalizedEnd = range > 0 ? ((end - minP) / range) * 100 : 0;
+    let topPx = (normalizedStart / 100) * total;
+    let heightPx = Math.max(2, ((normalizedEnd - normalizedStart) / 100) * total);
+
+    // 顶部对齐
+    const firstTermTop = 0;
+    const minTop = firstTermTop + 10;
+    if (topPx < minTop) {
+        const diff = minTop - topPx;
+        topPx = minTop;
+        heightPx = Math.max(2, heightPx - diff);
+    }
+
+    // 底部对齐
+    const lastTermTop = (100 / 100) * total;
+    const maxBottom = lastTermTop + 35;
+    const barBottom = topPx + heightPx;
+    if (barBottom > maxBottom) {
+        heightPx = Math.max(2, maxBottom - topPx);
+    }
+
+    const now = Date.now();
+    const isFuture = Number.isFinite(item?.startTimeMs) ? item.startTimeMs > now : start > 0;
+    const barColor = isFuture ? "rgba(145, 145, 145, 0.1)" : "#2199F8";
+    const beforeBg = isFuture ? "rgba(145, 145, 145, 0.1)" : "rgba(33, 153, 248, 0.1)";
+    return {
+        position: "absolute",
+        left: "46px",
+        width: "25px",
+        top: `${topPx}px`,
+        height: `${heightPx}px`,
+        background: barColor,
+        color: isFuture ? "#747778" : "#fff",
+        "--bar-before-bg": beforeBg,
+        zIndex: 2,
+    };
+};
+
+// 农事状态样式映射(0:默认,1-4:正常,5:完成,6:预警)
+const getArrangeStatusClass = (fw) => {
+    const t = fw?.flowStatus;
+    if (t == null) return "status-default";
+    if (t >= 0 && t <= 4) return "status-normal";
+    if (t === 5) return "status-complete";
+    if (t === 6) return "status-warning";
+    return "status-default";
+};
+
+// 计算 phenology-bar 的高度(px)
+const getPhenologyBarHeight = (item) => {
+    const p1 = Math.max(0, Math.min(100, Number(item?.progress) || 0));
+    const p2 = Math.max(0, Math.min(100, Number(item?.progress2) || 0));
+    const start = Math.min(p1, p2);
+    const end = Math.max(p1, p2);
+    const minP = minProgress.value;
+    const maxP = maxProgress.value;
+    const range = Math.max(1, maxP - minP);
+    const total = (solarTerms.value?.length || 0) * 1200;
+    const normalizedStart = range > 0 ? ((start - minP) / range) * 100 : 0;
+    const normalizedEnd = range > 0 ? ((end - minP) / range) * 100 : 0;
+    const heightPx = Math.max(2, ((normalizedEnd - normalizedStart) / 100) * total);
+    return heightPx;
+};
+
+// 计算 reproductive-item 的高度(px)
+const getReproductiveItemHeight = (phenologyItem) => {
+    const barHeight = getPhenologyBarHeight(phenologyItem);
+    const listLength = Array.isArray(phenologyItem?.reproductiveList) ? phenologyItem.reproductiveList.length : 1;
+    return listLength > 0 ? barHeight / listLength : barHeight;
+};
+
+const handleRowClick = (item) => {
+    emits("row-click", item);
+};
+
+const interactPopupRef = ref(null);
+const handleEdit = (item) => {
+    if (props.disableClick) return;
+    if (interactPopupRef.value) {
+        interactPopupRef.value.showPopup(item);
+    }
+};
+
+const containerIdData = ref(null);
+
+// 获取农事规划数据
+const getFarmWorkPlan = () => {
+    if (!props.farmId && !props.containerId) return;
+    let savedScrollTop = 0;
+    if (!isInitialLoad.value && timelineContainerRef.value) {
+        savedScrollTop = timelineContainerRef.value.scrollTop || 0;
+    }
+
+    VE_API.monitor
+        .farmWorkPlan({ farmId: props.farmId, containerId: props.containerId })
+        .then(({ data, code }) => {
+            if (code === 0) {
+                containerIdData.value = data.phenologyList[0].containerSpaceTimeId;
+                const list = Array.isArray(data?.solarTermsList) ? data.solarTermsList : [];
+                const filtered = list
+                    .filter((t) => t && t.type === 1)
+                    .map((t) => ({
+                        id:
+                            t.id ??
+                            t.solarTermsId ??
+                            t.termId ??
+                            `${t.name || t.solarTermsName || t.termName || "term"}-${t.createDate || ""}`,
+                        displayName: t.name || t.solarTermsName || t.termName || "节气",
+                        createDate: t.createDate || null,
+                        progress: Number(t.progress) || 0,
+                    }));
+                solarTerms.value = filtered;
+                // 物候期数据
+                phenologyList.value = Array.isArray(data?.phenologyList)
+                    ? data.phenologyList.map((it) => {
+                          const reproductiveList = Array.isArray(it.reproductiveList)
+                              ? it.reproductiveList.map((r) => {
+                                    const farmWorkArrangeList = Array.isArray(r.farmWorkArrangeList)
+                                        ? r.farmWorkArrangeList.map((fw) => ({
+                                              ...fw,
+                                              containerSpaceTimeId: it.containerSpaceTimeId,
+                                          }))
+                                        : [];
+                                    return {
+                                        ...r,
+                                        farmWorkArrangeList,
+                                    };
+                                })
+                              : [];
+
+                          return {
+                              id: it.id ?? it.phenologyId ?? it.name ?? `${it.progress}-${it.progress2}`,
+                              progress: Number(it.progress) || 0, // 起点 %
+                              progress2: Number(it.progress2) || 0, // 终点 %
+                              startTimeMs: safeParseDate(
+                                  it.startDate || it.beginDate || it.startTime || it.start || it.start_at
+                              ),
+                              reproductiveList,
+                          };
+                      })
+                    : [];
+
+                nextTick(() => {
+                    if (isInitialLoad.value) {
+                        const currentSeason = getCurrentSeason();
+                        handleSeasonClick(currentSeason);
+                        isInitialLoad.value = false;
+                    } else if (timelineContainerRef.value && savedScrollTop > 0) {
+                        timelineContainerRef.value.scrollTop = savedScrollTop;
+                    }
+                });
+            }
+        })
+        .catch((error) => {
+            console.error("获取农事规划数据失败:", error);
+            ElMessage.error("获取农事规划数据失败");
+        });
+};
+
+watch(
+    () => props.farmId || props.containerId,
+    (val) => {
+        if (val) {
+            isInitialLoad.value = true;
+            getFarmWorkPlan();
+        }
+    },
+    { immediate: true }
+);
+</script>
+
+<style scoped lang="scss">
+.timeline-container {
+    height: 100%;
+    overflow: auto;
+    position: relative;
+    box-sizing: border-box;
+    .timeline-list {
+        position: relative;
+    }
+    .timeline-middle-line {
+        position: absolute;
+        left: 15px; /* 位于节气文字列中间(列宽约30px) */
+        top: 0;
+        bottom: 0;
+        width: 2px;
+        background: #e8e8e8;
+        z-index: 1;
+    }
+    .phenology-bar {
+        display: flex;
+        align-items: stretch;
+        justify-content: center;
+        box-sizing: border-box;
+        .reproductive-list {
+            display: grid;
+            grid-auto-rows: 1fr; /* 子项等高,整体等分父高度 */
+            align-items: stretch;
+            justify-items: center; /* 子项居中 */
+            width: 100%;
+            height: 100%;
+            box-sizing: border-box;
+        }
+        .reproductive-item {
+            font-size: 12px;
+            text-align: center;
+            word-break: break-all;
+            writing-mode: vertical-rl;
+            text-orientation: upright;
+            letter-spacing: 3px;
+            width: 100%;
+            line-height: 23px;
+            color: inherit;
+            position: relative;
+            &.horizontal-text {
+                writing-mode: horizontal-tb;
+                text-orientation: mixed;
+                letter-spacing: normal;
+                line-height: calc(var(--item-height, 15px) - 3px);
+            }
+            &.vertical-lr-text {
+                writing-mode: vertical-lr;
+                text-orientation: upright;
+                letter-spacing: 3px;
+                line-height: 26px;
+            }
+            .arranges {
+                position: absolute;
+                left: 40px; /* 列与中线右侧一段距离 */
+                top: 0;
+                z-index: 3;
+                display: flex;
+                max-width: calc(100vw - 100px);
+                gap: 12px;
+                letter-spacing: 0px;
+                .arrange-card {
+                    width: 97%;
+                    border: 0.5px solid #2199f8;
+                    border-radius: 8px;
+                    background: #fff;
+                    box-sizing: border-box;
+                    position: relative;
+                    padding: 8px;
+                    writing-mode: horizontal-tb;
+                    .card-header {
+                        display: flex;
+                        justify-content: space-between;
+                        align-items: center;
+                        .header-left {
+                            display: flex;
+                            align-items: center;
+                            gap: 8px;
+                            .farm-work-name {
+                                font-size: 14px;
+                                font-weight: 500;
+                                color: #1d2129;
+                            }
+                            .tag-standard {
+                                padding: 0 8px;
+                                background: rgba(119, 119, 119, 0.1);
+                                border-radius: 25px;
+                                font-weight: 400;
+                                font-size: 12px;
+                                color: #000;
+                            }
+                        }
+                        .header-right {
+                            font-size: 12px;
+                            color: #808080;
+                            padding: 0 8px;
+                            border-radius: 25px;
+                        }
+                    }
+                    .card-content {
+                        color: #909090;
+                        text-align: left;
+                        line-height: 1.55;
+                        margin: 4px 0 2px 0;
+                        .edit-link {
+                            color: #2199f8;
+                            margin-left: 5px;
+                        }
+                    }
+                    .status-icon {
+                        position: absolute;
+                        right: -8px;
+                        bottom: -8px;
+                        z-index: 3;
+                    }
+                    &::before {
+                        content: "";
+                        position: absolute;
+                        left: -6px;
+                        top: 50%;
+                        transform: translateY(-50%);
+                        width: 0;
+                        height: 0;
+                        border-top: 5px solid transparent;
+                        border-bottom: 5px solid transparent;
+                        border-right: 5px solid #2199f8;
+                    }
+                }
+                .arrange-card.status-warning {
+                    border-color: #ff953d;
+                    &::before {
+                        border-right-color: #ff953d;
+                    }
+                }
+                .arrange-card.status-complete {
+                    border-color: #1ca900;
+                    &::before {
+                        border-right-color: #1ca900;
+                    }
+                }
+                .arrange-card.status-normal {
+                    border-color: #2199f8;
+                    &::before {
+                        border-right-color: #2199f8;
+                    }
+                }
+            }
+        }
+    }
+    .reproductive-item + .reproductive-item {
+        border-top: 2px solid #fff;
+    }
+    .phenology-bar + .phenology-bar {
+        border-top: 2px solid #fff;
+    }
+    .timeline-term {
+        position: absolute;
+        width: 30px;
+        padding-right: 16px;
+        display: flex;
+        align-items: flex-start;
+        z-index: 2; /* 置于中线之上 */
+        .term-name {
+            display: inline-block;
+            width: 100%;
+            height: 46px;
+            line-height: 30px;
+            background: #f5f7fb;
+            font-size: 13px;
+            word-break: break-all;
+            writing-mode: vertical-rl;
+            text-orientation: upright;
+            color: rgba(174, 174, 174, 0.6);
+            text-align: center;
+        }
+    }
+}
+</style>

+ 128 - 44
src/components/pageComponents/FarmWorkPlanTimeline.vue

@@ -162,12 +162,110 @@ const maxProgress = computed(() => {
     return progresses.length > 0 ? Math.max(...progresses) : 100;
 });
 
+// 计算物候期需要的实际高度(基于农事数量)
+const getPhenologyRequiredHeight = (item) => {
+    // 统计该物候期内的农事数量
+    let farmWorkCount = 0;
+    
+    if (Array.isArray(item.reproductiveList)) {
+        item.reproductiveList.forEach((reproductive) => {
+            if (Array.isArray(reproductive.farmWorkArrangeList)) {
+                farmWorkCount += reproductive.farmWorkArrangeList.length;
+            }
+        });
+    }
+    
+    // 如果没有农事,给一个最小高度
+    if (farmWorkCount === 0) {
+        return 50; // 最小50px
+    }
+    
+    // 每个农事卡片的高度(根据实际内容,卡片高度可能因内容而异)
+    const farmWorkCardHeight = 100; // 增加卡片高度估算,确保能容纳内容
+    // 卡片之间的间距(与CSS中的gap保持一致)
+    const cardGap = 12;
+    
+    // 计算总高度:卡片数量 * 卡片高度 + (卡片数量 - 1) * 间距
+    // 如果有多个卡片,需要加上它们之间的间距
+    const totalHeight = farmWorkCount * farmWorkCardHeight + (farmWorkCount > 1 ? (farmWorkCount - 1) * cardGap : 0);
+    
+    // 返回总高度,并增加足够的余量(30px)确保所有农事都能完整显示,不会堆叠
+    return Math.max(totalHeight + 30, 50); // 最小50px,额外加30px余量确保不重叠
+};
+
+// 计算所有物候期的累积位置和总高度
+const calculatePhenologyPositions = () => {
+    let currentTop = 10; // 起始位置,留出顶部间距
+    const positions = new Map();
+    
+    // 按progress排序物候期,确保按时间顺序排列
+    const sortedPhenologyList = [...phenologyList.value].sort((a, b) => {
+        const aProgress = Math.min(Number(a?.progress) || 0, Number(a?.progress2) || 0);
+        const bProgress = Math.min(Number(b?.progress) || 0, Number(b?.progress2) || 0);
+        return aProgress - bProgress;
+    });
+    
+    sortedPhenologyList.forEach((phenology) => {
+        const height = getPhenologyRequiredHeight(phenology);
+        // 使用与数据生成时相同的ID生成逻辑
+        const itemId = phenology.id ?? phenology.phenologyId ?? phenology.name ?? `${phenology.progress}-${phenology.progress2}`;
+        positions.set(itemId, {
+            top: currentTop,
+            height: height,
+        });
+        currentTop += height; // 紧挨着下一个物候期,不留间距
+    });
+    
+    return {
+        positions,
+        totalHeight: currentTop + 12, // 总高度 = 最后一个物候期底部 + 底部间距
+    };
+};
+
+// 计算所有农事的总高度(基于物候期紧挨排列)
+const calculateTotalHeightByFarmWorks = () => {
+    const { totalHeight } = calculatePhenologyPositions();
+    
+    // 计算最后一个物候期的底部位置
+    let lastPhenologyBottom = 0;
+    if (phenologyList.value && phenologyList.value.length > 0) {
+        const sortedPhenologyList = [...phenologyList.value].sort((a, b) => {
+            const aProgress = Math.min(Number(a?.progress) || 0, Number(a?.progress2) || 0);
+            const bProgress = Math.min(Number(b?.progress) || 0, Number(b?.progress2) || 0);
+            return aProgress - bProgress;
+        });
+        
+        let currentTop = 10; // 起始位置
+        sortedPhenologyList.forEach((phenology) => {
+            const height = getPhenologyRequiredHeight(phenology);
+            currentTop += height;
+        });
+        lastPhenologyBottom = currentTop; // 最后一个物候期的底部位置
+    }
+    
+    // 直接使用最后一个物候期的底部位置作为总高度
+    // 在getTermStyle中,我们已经调整了最后一个节气的top位置(total - 46)
+    // 这样最后一个节气的底部(total - 46 + 46 = total)就能与物候期底部对齐
+    if (lastPhenologyBottom > 0) {
+        const baseHeight = (solarTerms.value?.length || 0) * 50;
+        // 总高度 = 最后一个物候期的底部位置
+        // 这样最后一个节气的底部就能对齐到物候期的底部
+        return Math.max(lastPhenologyBottom, totalHeight, baseHeight, 500);
+    }
+    
+    // 基础高度:每个节气至少需要一定高度,确保节气标签能显示
+    const baseHeight = (solarTerms.value?.length || 0) * 50;
+    
+    // 返回物候期总高度和基础高度的较大值
+    return Math.max(totalHeight, baseHeight, 500); // 最小500px
+};
+
 // 列表高度
 const getListStyle = computed(() => {
     const minP = minProgress.value;
     const maxP = maxProgress.value;
     const range = Math.max(1, maxP - minP); // 避免除0
-    const total = (solarTerms.value?.length || 0) * 1200;
+    const total = calculateTotalHeightByFarmWorks();
     const minH = range === 0 ? 0 : total;
     return { minHeight: `${minH}px` };
 });
@@ -177,10 +275,19 @@ const getTermStyle = (t) => {
     const minP = minProgress.value;
     const maxP = maxProgress.value;
     const range = Math.max(1, maxP - minP); // 避免除0
-    const total = (solarTerms.value?.length || 0) * 1200;
+    const total = calculateTotalHeightByFarmWorks();
+    const termHeight = 46; // 节气的实际高度(.term-name的高度)
+    
     // 将progress映射到0开始的位置,最小progress对应top: 0
     const normalizedP = range > 0 ? ((p - minP) / range) * 100 : 0;
-    const top = (normalizedP / 100) * total;
+    let top = (normalizedP / 100) * total;
+    
+    // 如果是最后一个节气(progress = maxP),调整top位置,使其底部正好在total位置
+    // 这样最后一个节气的底部就能与最后一个物候期的底部对齐
+    if (p === maxP && range > 0) {
+        top = total - termHeight; // 让最后一个节气的底部正好在total位置
+    }
+    
     return {
         position: "absolute",
         top: `${top}px`,
@@ -208,7 +315,7 @@ const handleSeasonClick = (seasonValue) => {
     const minP = minProgress.value;
     const maxP = maxProgress.value;
     const range = Math.max(1, maxP - minP);
-    const total = (solarTerms.value?.length || 0) * 1200;
+    const total = calculateTotalHeightByFarmWorks(); // 使用动态计算的总高度
     const normalizedP = range > 0 ? ((p - minP) / range) * 100 : 0;
     const targetTop = (normalizedP / 100) * total; // 内容内的像素位置
     const wrap = timelineContainerRef.value;
@@ -223,41 +330,28 @@ const handleSeasonClick = (seasonValue) => {
 
 // 物候期覆盖条样式
 const getPhenologyBarStyle = (item) => {
+    const { positions } = calculatePhenologyPositions();
+    // 使用与数据生成时相同的ID生成逻辑
+    const itemId = item.id ?? item.phenologyId ?? item.name ?? `${item.progress}-${item.progress2}`;
+    const position = positions.get(itemId);
+    
+    // 如果找不到位置信息,使用默认值
+    let topPx = 10;
+    let heightPx = 50;
+    
+    if (position) {
+        topPx = position.top;
+        heightPx = position.height;
+    }
+
     const p1 = Math.max(0, Math.min(100, Number(item?.progress) || 0));
     const p2 = Math.max(0, Math.min(100, Number(item?.progress2) || 0));
     const start = Math.min(p1, p2);
-    const end = Math.max(p1, p2);
-    const minP = minProgress.value;
-    const maxP = maxProgress.value;
-    const range = Math.max(1, maxP - minP);
-    const total = (solarTerms.value?.length || 0) * 1200; // 有效绘制区高度(px)
-    // 将progress映射到0开始的位置
-    const normalizedStart = range > 0 ? ((start - minP) / range) * 100 : 0;
-    const normalizedEnd = range > 0 ? ((end - minP) / range) * 100 : 0;
-    let topPx = (normalizedStart / 100) * total;
-    let heightPx = Math.max(2, ((normalizedEnd - normalizedStart) / 100) * total);
-
-    // 顶部对齐
-    const firstTermTop = 0;
-    const minTop = firstTermTop + 10;
-    if (topPx < minTop) {
-        const diff = minTop - topPx;
-        topPx = minTop;
-        heightPx = Math.max(2, heightPx - diff);
-    }
-
-    // 底部对齐
-    const lastTermTop = (100 / 100) * total;
-    const maxBottom = lastTermTop + 35;
-    const barBottom = topPx + heightPx;
-    if (barBottom > maxBottom) {
-        heightPx = Math.max(2, maxBottom - topPx);
-    }
-
     const now = Date.now();
     const isFuture = Number.isFinite(item?.startTimeMs) ? item.startTimeMs > now : start > 0;
     const barColor = isFuture ? "rgba(145, 145, 145, 0.1)" : "#2199F8";
     const beforeBg = isFuture ? "rgba(145, 145, 145, 0.1)" : "rgba(33, 153, 248, 0.1)";
+    
     return {
         position: "absolute",
         left: "46px",
@@ -283,18 +377,8 @@ const getArrangeStatusClass = (fw) => {
 
 // 计算 phenology-bar 的高度(px)
 const getPhenologyBarHeight = (item) => {
-    const p1 = Math.max(0, Math.min(100, Number(item?.progress) || 0));
-    const p2 = Math.max(0, Math.min(100, Number(item?.progress2) || 0));
-    const start = Math.min(p1, p2);
-    const end = Math.max(p1, p2);
-    const minP = minProgress.value;
-    const maxP = maxProgress.value;
-    const range = Math.max(1, maxP - minP);
-    const total = (solarTerms.value?.length || 0) * 1200;
-    const normalizedStart = range > 0 ? ((start - minP) / range) * 100 : 0;
-    const normalizedEnd = range > 0 ? ((end - minP) / range) * 100 : 0;
-    const heightPx = Math.max(2, ((normalizedEnd - normalizedStart) / 100) * total);
-    return heightPx;
+    // 直接使用基于农事数量的高度
+    return getPhenologyRequiredHeight(item);
 };
 
 // 计算 reproductive-item 的高度(px)

+ 35 - 54
src/views/old_mini/create_farm/index.vue

@@ -123,18 +123,10 @@
                                             <div class="unit">亩</div>
                                         </div>
                                     </el-form-item>
-                                    <el-form-item label="客户类型" prop="schemeId" class="select-wrap client-wrap">
-                                        <el-select
-                                            class="select-item"
-                                            v-model="ruleForm.schemeId"
-                                            placeholder="请选择"
-                                        >
-                                            <el-option
-                                                v-for="(item, index) in clientTypeList"
-                                                :key="index"
-                                                :label="item.alias"
-                                                :value="item.id"
-                                            />
+                                    <el-form-item label="客户类型" prop="userType" class="select-wrap client-wrap">
+                                        <el-select class="select-item" v-model="ruleForm.userType" placeholder="请选择">
+                                            <el-option label="普通用户" :value="1" />
+                                            <el-option label="托管用户" :value="2" />
                                         </el-select>
                                     </el-form-item>
                                     <el-form-item label="农场名称" prop="name">
@@ -329,17 +321,6 @@ onMounted(() => {
     }
 });
 
-// 客户类型列表
-const clientTypeList = ref([])
-const getClientTypeList = (containerId) => {
-    VE_API.home.listMySchemes({containerId}).then(({ data }) => {
-        clientTypeList.value = data || [];
-        if(data && data.length) {
-            ruleForm.schemeId = data[0].id;
-        }
-    });
-};
-
 const polygonArr = ref(null);
 const paramsType = ref(null);
 onActivated(() => {
@@ -515,7 +496,7 @@ const ruleForm = reactive({
     name: "",
     fzr: "",
     tel: "",
-    schemeId: null,
+    userType: 1,
     defaultFarm: 0, // 0:否 1:是
 });
 // 自定义验证规则:验证面积必须是大于0的数字
@@ -536,7 +517,7 @@ const validateMianji = (rule, value, callback) => {
 
 const rules = reactive({
     address: [{ required: true, message: "请选择农场位置", trigger: "blur" }],
-    schemeId: [{ required: true, message: "请选择客户类型", trigger: "blur" }],
+    userType: [{ required: true, message: "请选择客户类型", trigger: "blur" }],
     mu: [
         { required: true, message: "请输入农场面积", trigger: "blur" },
         { validator: validateMianji, trigger: ["blur", "change"] },
@@ -627,21 +608,23 @@ const submitForm = (formEl) => {
                     } else if (fromPage === "details") {
                         router.go(-1);
                     } else {
-                        if(route.query.miniJson) {
+                        if (route.query.miniJson) {
                             const json = JSON.parse(route.query.miniJson);
                             //上传图片
-                            VE_API.ali.uploadImg({
-                                farmId: res.data.id,
-                                images: json.images,
-                                uploadDate: formatDate(new Date()),
-                            }).then(({ code,msg }) => {
-                                if(code === 0) {
-                                    showSuccessPopup.value = true;
-                                }else{
-                                    ElMessage.error(msg);
-                                }
-                            });
-                        }else{
+                            VE_API.ali
+                                .uploadImg({
+                                    farmId: res.data.id,
+                                    images: json.images,
+                                    uploadDate: formatDate(new Date()),
+                                })
+                                .then(({ code, msg }) => {
+                                    if (code === 0) {
+                                        showSuccessPopup.value = true;
+                                    } else {
+                                        ElMessage.error(msg);
+                                    }
+                                });
+                        } else {
                             router.replace(`/home`);
                         }
                     }
@@ -746,7 +729,7 @@ watch(
 const specieList = ref([]);
 
 function getSpecieList() {
-    return VE_API.farm.fetchSpecieList({point: centerPoint.value}).then(({ data }) => {
+    return VE_API.farm.fetchSpecieList({ point: centerPoint.value }).then(({ data }) => {
         specieList.value = data;
         return data;
     });
@@ -754,10 +737,8 @@ function getSpecieList() {
 
 function changeSpecie(v) {
     getFruitsTypeItemList(v.id);
-    ruleForm.schemeId = null;
     // 清空品种选择
     ruleForm.typeId = "";
-    getClientTypeList(v.defaultContainerId);
     // 只有在创建模式下且用户没有手动修改过农场名称时,才自动设置农场名称
     if (route.query.type !== "edit" && !isFarmNameManuallyModified.value) {
         ruleForm.name = farmCity.value + v.name + "农场";
@@ -771,16 +752,16 @@ function getFruitsTypeItemList(parentId) {
     });
 }
 
-  /**
-   * 格式化日期为 YYYY-MM-DD 格式
-   * @param {Date} date - 日期对象
-   * @returns {string} 格式化后的日期字符串
-   */
+/**
+ * 格式化日期为 YYYY-MM-DD 格式
+ * @param {Date} date - 日期对象
+ * @returns {string} 格式化后的日期字符串
+ */
 function formatDate(date) {
-    const year = date.getFullYear()
-    const month = String(date.getMonth() + 1).padStart(2, '0')
-    const day = String(date.getDate()).padStart(2, '0')
-    return `${year}-${month}-${day}`
+    const year = date.getFullYear();
+    const month = String(date.getMonth() + 1).padStart(2, "0");
+    const day = String(date.getDate()).padStart(2, "0");
+    return `${year}-${month}-${day}`;
 }
 
 function backgToHome() {
@@ -790,7 +771,7 @@ function backgToHome() {
     const fromPage = route.query.from;
     if (route.query.miniJson) {
         const json = JSON.parse(route.query.miniJson);
-        if(json.isMini) {
+        if (json.isMini) {
             const dropdownGardenItem = ref({
                 organId: json.farmId,
                 periodId: json.periodId,
@@ -803,7 +784,7 @@ function backgToHome() {
                 url: `/pages/subPages/new_recognize/index?gardenData=${JSON.stringify(dropdownGardenItem.value)}`,
             });
         }
-    }else{
+    } else {
         if (fromPage && fromPage !== "details") {
             router.replace(`/${fromPage}`);
             return;
@@ -1157,8 +1138,8 @@ function handleMianjiInput(value) {
                             width: fit-content;
                         }
                     }
-                    &.client-wrap{
-                        ::v-deep{
+                    &.client-wrap {
+                        ::v-deep {
                             .el-select__wrapper {
                                 justify-content: flex-start;
                             }

+ 1 - 1
src/views/old_mini/home/subPages/prescriptionPage.vue

@@ -120,7 +120,7 @@ const handlePage = () => {
     }
     
     // 传递所有农场相关的参数,以便在 agricultural_plan 页面创建农场
-    const farmParams = ['wkt', 'speciesId', 'containerId', 'agriculturalCreate', 'geom', 'address', 'mu', 'name', 'fzr', 'tel', 'defaultFarm', 'typeId', 'speciesName','schemeId'];
+    const farmParams = ['wkt', 'speciesId', 'containerId', 'agriculturalCreate', 'geom', 'address', 'mu', 'name', 'fzr', 'tel', 'defaultFarm', 'typeId', 'speciesName','userType'];
     farmParams.forEach(key => {
         if (route.query[key] !== undefined) {
             queryParams[key] = route.query[key];

+ 4 - 2
src/views/old_mini/mine/pages/teamManage.vue

@@ -420,9 +420,11 @@ const handleConfirm = () => {
 const handleAddTeamMember = async () => {
     if (route.query.add) {
         if (filterList.value.length) {
-            // 批量设置管理员时,默认勾选全部权限
+            // 批量设置管理员时,默认勾选全部权限(排除"农事规划")
             if (Array.isArray(permissionList.value) && permissionList.value.length > 0) {
-                selectedPermission.value = permissionList.value.map((p) => p.code);
+                selectedPermission.value = permissionList.value
+                    .filter((p) => p.name !== "农事规划")
+                    .map((p) => p.code);
             }
             showPermissionPopup.value = true;
         } else {

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

@@ -37,7 +37,7 @@
                     :farmId="route.query.farmId"
                     :containerId="containerIdData"
                     @row-click="handleRowClick"
-                    :disableClick="!hasPlanPermission"
+                    :disableClick="!hasPlanPermission || active === tabs[0]?.id"
                 />
             </div>
         </div>

+ 20 - 12
src/views/old_mini/plan/index.vue

@@ -13,12 +13,13 @@
                 @change="handleTabChange"
                 class="tabs-list"
             />
-            <farm-work-plan-timeline
-                class="timeline-wrap"
-                pageType="plant"
-                :containerId="containerId"
-                :disableClick="true"
-            />
+            <div class="timeline-wrap">
+                <farm-work-plan-timeline
+                    pageType="plant"
+                    :containerId="containerId"
+                    :disableClick="true"
+                />
+            </div>
         </div>
     </div>
     <div class="custom-bottom-fixed-btns">
@@ -72,7 +73,7 @@ const getListMySchemes = () => {
         if (data.length) {
             tabs.value = data || [];
             const index = data.findIndex((item) => item.containerId == route.query.containerId);
-            active.value = route.query.schemeId || data[index].id;
+            active.value = data[index].id;
             containerId.value = route.query.containerId;
         }
     });
@@ -101,7 +102,6 @@ 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,10 +129,18 @@ const handleConfirmPlan = () => {
         .then((res) => {
             if (res.code === 0) {
                 shareData.value = res.data;
-                ElMessage.success("创建成功");
-                setTimeout(() => {
-                    handleClickOverlay();
-                }, 1000);
+                //选择方案
+                VE_API.home.selectSchemes({ schemeId: active.value ,farmId:res.data.id}).then(({code}) => {
+                    if (code === 0) {
+                        ElMessage.success("创建成功");
+                        setTimeout(() => {
+                            handleClickOverlay();
+                        }, 1000);
+                    } else {
+                        ElMessage.error(res.msg || '创建失败');
+                    }
+                });
+                
             } else {
                 ElMessage.error(res.msg || "创建失败");
             }