| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415 |
- <template>
- <floating-panel
- class="risk-report-panel"
- :class="{
- 'risk-report-panel--dragging': isDragging,
- 'risk-report-panel--plot': viewType === 'plot',
- 'risk-report-panel--plot-fullscreen': isPlotFullscreen,
- }"
- :style="panelMotionStyle"
- v-model:height="height"
- :anchors="anchors"
- :duration="0.36"
- :content-draggable="true"
- @height-change="handleHeightChange"
- >
- <template v-if="viewType === 'risk'">
- <div class="panel-header-zone">
- <div class="panel-header" :class="{ 'panel-header--en': locale === 'en' }">
- <div class="panel-header__row">
- <div class="panel-header__left">
- <span class="panel-header__bar"></span>
- <span
- class="panel-header__title panel-header__title--toggle"
- @click="toggleLocale"
- >{{ t("growthReport.weatherRiskReport") }}</span>
- <span v-if="locale !== 'en'" class="panel-header__date">{{ reportDate }}</span>
- </div>
- <span v-if="locale === 'en'" class="panel-header__date">{{ reportDate }}</span>
- <div
- v-if="locale !== 'en'"
- class="panel-header__switch"
- @click="handleSwitchCategory"
- >
- <span>{{ t("growthReport.switchCategory") }}</span>
- <icon name="arrow-down" class="panel-header__switch-icon" />
- </div>
- </div>
- <div
- v-if="locale === 'en'"
- class="panel-header__switch panel-header__switch--en"
- @click="handleSwitchCategory"
- >
- <span>{{ t("growthReport.switchCategory") }}</span>
- <icon name="arrow-down" class="panel-header__switch-icon" />
- </div>
- </div>
- </div>
- <div class="panel-body">
- <risk-report-content
- :loading="loading"
- :risk-section="riskSection"
- :advice-list="adviceList"
- />
- </div>
- </template>
- <plot-detail-content
- v-else
- :detail="plotDetail"
- :fullscreen="isPlotFullscreen"
- @close="emit('closePlotDetail')"
- />
- </floating-panel>
- </template>
- <script setup>
- import { FloatingPanel, Icon } from "vant";
- import { computed, ref, watch } from "vue";
- import { useStore } from "vuex";
- import { useI18n } from "@/i18n";
- import PlotDetailContent from "./PlotDetailContent.vue";
- import RiskReportContent from "./RiskReportContent.vue";
- const { t, toggleLocale, locale } = useI18n();
- const store = useStore();
- const tabBarHeight = computed(() => store.state.home.tabBarHeight);
- const props = defineProps({
- viewType: {
- type: String,
- default: "risk",
- },
- plotDetail: {
- type: Object,
- default: () => ({}),
- },
- });
- const emit = defineEmits(["switchCategory", "expandProgress", "closePlotDetail"]);
- const MONTHS_EN = [
- "January", "February", "March", "April", "May", "June",
- "July", "August", "September", "October", "November", "December",
- ];
- const formatReportDate = (date = new Date(), lang = "zh") => {
- const year = date.getFullYear();
- const month = date.getMonth() + 1;
- const day = date.getDate();
- if (lang === "en") {
- return `${MONTHS_EN[month - 1]} ${day}, ${year}`;
- }
- return `${year}.${String(month).padStart(2, "0")}.${String(day).padStart(2, "0")}`;
- };
- const reportDate = computed(() => formatReportDate(new Date(), locale.value));
- const loading = ref(false);
- const riskSection = computed(() => ({
- title: "高温高湿风险",
- summary:
- "预计高温高湿风险达到高风险等级(Ⅲ级),持续性高温高湿不仅直接加重病虫危害,还将迫使种植户增加农药施用频次,推高生产成本,进而影响稻米品质与种植效益,构成基地水稻中后期生产的关键气象风险。",
- items: [
- {
- description:
- "预计未来十天潢涌基地将进入 持续高温高湿状态,日均温普遍维持在 28℃ 以上,相对湿度超过 80%,为水稻病虫害的发生与流行提供了充分的气象条件。在此背景下,水稻纹枯病 可能急剧发展,经函数对病虫气象适宜度进行计算,并叠加前期积累的气象胁迫背景,计算得到病虫胁迫指数为 6(0~9范围,0~3为低风险,4~6为中风险,7~9为高风险),达到 高风险等级(Ⅲ级),重发田块发病率 可超过 60%,可导致 10%~15% 的产量损失。",
- boldKeywords: [
- "持续高温高湿状态",
- "28℃",
- "80%",
- "水稻纹枯病",
- // "6",
- "高风险等级",
- "重发田块发病率",
- "60%",
- "10%~15%",
- ],
- },
- {
- description:
- "灌浆期遇高湿阴雨天气,稻瘟病 呈 中等偏重 发生趋势,感病品种 穗颈瘟 发病率可达 22.8% 。同时,稻飞虱、稻纵卷叶螟等迁飞性害虫在高温高湿环境中繁殖速度加快,若与台风外围虫源叠加,可造成 20% 左右的减产风险。此外,25~30℃日均温与80%以上相对湿度的组合,极有利于 水稻跗线螨 种群快速增长,可能导致叶片褪绿、千粒重下降 3%~5%。",
- boldKeywords: [
- "稻瘟病",
- "中等偏重",
- "穗颈瘟",
- "22.8%",
- "20%",
- "水稻跗线螨",
- " 3%~5%",
- ],
- },
- ],
- }));
- const adviceList = computed(() => [
- {
- title: "田间水肥调控(即刻执行)",
- description:
- "叶面补钾增强抗性:每亩喷施磷酸二氢钾100克,兑水30公斤,提高茎秆硬度和植株抗病能力。"
- },
- {
- title: "应急防控(未来3天内完成)",
- description:
- "立即喷施苯醚甲环唑·嘧菌酯悬浮剂,或井冈霉素水剂,重点喷施水稻茎秆中下部。重病田块间隔7天再补防一次。",
- },
- ]);
- const handleSwitchCategory = () => {
- emit("switchCategory");
- };
- const anchors = computed(() => {
- const viewportHeight = window.innerHeight - tabBarHeight.value;
- return [
- Math.round(viewportHeight * 0.4),
- window.innerHeight,
- ];
- });
- const height = ref(anchors.value[0]);
- const isDragging = ref(false);
- let dragEndTimer = null;
- const expandProgress = computed(() => {
- const min = anchors.value[0];
- const max = anchors.value[anchors.value.length - 1];
- if (max <= min) return 0;
- return Math.min(1, Math.max(0, (height.value - min) / (max - min)));
- });
- const isPlotFullscreen = computed(() => props.viewType === "plot" && expandProgress.value > 0.85);
- const panelMotionStyle = computed(() => {
- const progress = expandProgress.value;
- const margin = 10 * (1 - progress);
- const radius = 16 * (1 - progress);
- const headerScale = 1 + progress * 0.12;
- return {
- "--panel-radius": `${radius}px`,
- "--panel-progress": progress,
- left: `${margin}px`,
- width: `calc(100% - ${margin * 2}px)`,
- zIndex: progress > 0.82 ? 20 : 10,
- paddingTop: progress > 0.9 ? "env(safe-area-inset-top, 0px)" : "0px",
- "--header-bar-scale": headerScale,
- };
- });
- const syncExpandProgress = () => {
- emit("expandProgress", expandProgress.value);
- };
- watch(expandProgress, syncExpandProgress, { immediate: true });
- watch(height, () => {
- isDragging.value = true;
- if (dragEndTimer) {
- clearTimeout(dragEndTimer);
- }
- dragEndTimer = setTimeout(() => {
- isDragging.value = false;
- }, 380);
- });
- watch(anchors, (nextAnchors) => {
- if (height.value > nextAnchors[nextAnchors.length - 1]) {
- height.value = nextAnchors[0];
- }
- });
- watch(
- () => props.viewType,
- (type) => {
- if (type === "plot") {
- height.value = anchors.value[0];
- }
- }
- );
- const handleHeightChange = () => {
- syncExpandProgress();
- };
- </script>
- <style lang="scss" scoped>
- .risk-report-panel {
- z-index: 10;
- will-change: left, width;
- &.risk-report-panel--dragging {
- ::v-deep .van-floating-panel__header-bar {
- transform: scaleX(calc(var(--header-bar-scale, 1)));
- }
- }
- &.risk-report-panel--plot-fullscreen {
- ::v-deep {
- .van-floating-panel__header {
- background: #f5f7fb;
- }
- .van-floating-panel__content {
- background: #f5f7fb;
- }
- }
- }
- &.risk-report-panel--plot {
- ::v-deep {
- .van-floating-panel__header {
- background: #fff;
- }
- .van-floating-panel__header-bar {
- background: #c6c6c6;
- }
- .van-floating-panel__content {
- background: #fff;
- }
- }
- }
- ::v-deep {
- .van-floating-panel__header {
- height: 18px;
- background: linear-gradient(180deg, #acd5fb 0%, #bcddfc 100%);
- border-radius: var(--panel-radius, 16px) var(--panel-radius, 16px) 0 0;
- }
- .van-floating-panel__header-bar {
- width: 36px;
- height: 4px;
- background: rgba(255, 255, 255, 0.95);
- border-radius: 4px;
- transform: scaleX(var(--header-bar-scale, 1));
- transition: transform 0.2s ease;
- }
- .van-floating-panel__content {
- overflow-y: auto;
- padding-bottom: env(safe-area-inset-bottom);
- background: linear-gradient(180deg, #d2ebff 38%, #e3f2fd 68%, #ffffff 100%);
- }
- }
- }
- .panel-header-zone {
- padding-bottom: 4px;
- background: linear-gradient(180deg, #bcddfc 0%, #d9ebfd 100%);
- }
- .panel-header {
- display: flex;
- align-items: center;
- justify-content: space-between;
- gap: 8px;
- padding: 2px 12px 8px;
- box-sizing: border-box;
- &__row {
- display: flex;
- align-items: center;
- justify-content: space-between;
- width: 100%;
- gap: 8px;
- min-width: 0;
- }
- &--en {
- flex-direction: column;
- align-items: flex-start;
- gap: 10px;
- padding-bottom: 10px;
- .panel-header__row {
- width: 100%;
- }
- .panel-header__left {
- flex: 1;
- min-width: 0;
- }
- .panel-header__title {
- font-size: 17px;
- font-weight: 600;
- color: #000;
- }
- .panel-header__date {
- flex-shrink: 0;
- padding: 4px 8px;
- font-size: 12px;
- color: #313131;
- background: rgba(255, 255, 255, 0.72);
- border-radius: 4px;
- }
- .panel-header__switch--en {
- padding: 4px 10px;
- border-radius: 4px;
- border-color: rgba(33, 153, 248, 0.75);
- }
- }
- &__left {
- display: flex;
- align-items: center;
- gap: 6px;
- }
- &__bar {
- width: 4px;
- height: 16px;
- border-radius: 2px;
- background: #2199f8;
- }
- &__title {
- font-size: 16px;
- font-weight: 500;
- &--toggle {
- cursor: pointer;
- user-select: none;
- }
- }
- &__date {
- padding: 2px 6px;
- font-size: 12px;
- color: #313131;
- background: rgba(255, 255, 255, 0.5);
- border-radius: 2px;
- }
- &__switch {
- display: flex;
- align-items: center;
- gap: 2px;
- padding: 5px 10px;
- font-size: 12px;
- color: #2199f8;
- background: #fff;
- border: 1px solid rgba(33, 153, 248, 0.65);
- border-radius: 6px;
- white-space: nowrap;
- flex-shrink: 0;
- }
- &__switch-icon {
- font-size: 12px;
- color: #2199f8;
- }
- }
- .panel-body {
- margin: 0 10px;
- background: #fff;
- border-radius: 8px;
- padding: 10px;
- }
- </style>
|