| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346 |
- <template>
- <div class="farm-info-group">
- <!-- 顶部标题栏 -->
- <div class="info-header">
- <div class="back-btn" v-if="!farmList.length" @click="handleBack">返回</div>
- <div class="title">
- <img class="title-icon" src="@/assets/images/common/chart-icon.png" alt="" />
- <span class="title-text">{{ farmList.length ? "农场列表" : "荔博园" }}</span>
- </div>
- </div>
- <!-- 主要内容区域 -->
- <div class="info-content" :style="{ height: !farmList.length ? 'calc(100% - 168px)' : 'calc(100% - 50px)' }">
- <div class="farm-info" v-for="item in farmList" :key="item" @click="handleFarmInfo(item)">
- <div class="lz-icon">
- <img src="@/assets/images/warningHome/lz-icon.png" alt="" />
- </div>
- <!-- 右侧信息区域 -->
- <div class="info-right">
- <div class="info-item farm-code">
- <span class="info-label">{{ !farmList.length ? '农场编号:GZ86770' : item.farmName }}</span>
- <div class="tags">
- <span class="tag">荔枝</span>
- <span class="tag">井岗红糯</span>
- </div>
- </div>
- <div class="info-item">
- <span class="info-label">农场面积:</span>
- <span class="info-value">{{ item.plantArea && item.plantArea.toFixed(2) || 0 }}亩</span>
- </div>
- <div class="info-item">
- <span class="info-label">农场位置:</span>
- <span class="info-value">广东省广州市***</span>
- </div>
- <div class="info-item">
- <span class="info-label">权属人:</span>
- <span class="info-value">张扬</span>
- </div>
- </div>
- </div>
- <template v-if="!farmList.length">
- <div class="tabs">
- <div
- v-for="tab in tabs"
- :key="tab.key"
- class="tab-item"
- :class="{ active: activeTab === tab.key }"
- @click="activeTab = tab.key"
- >
- {{ tab.label }}
- </div>
- </div>
- <div class="tab-content">
- <div class="timeline" v-if="activeTab === 'crop'">
- <div class="timeline-item" v-for="item in timelineList" :key="item.id">
- <div class="timeline-left">
- <div class="dot"></div>
- <div class="line"></div>
- </div>
- <div class="timeline-right">
- <div class="date">{{ item.date }}</div>
- <div class="text">{{ item.text }}</div>
- </div>
- </div>
- </div>
- <div v-else class="perception-content">
- <div class="perception-tabs">
- <div
- v-for="tab in perceptionTabs"
- :key="tab.key"
- class="perception-tab"
- :class="{ 'perception-tab--active': perceptionActive === tab.key }"
- @click="perceptionActive = tab.key"
- >
- <span class="label">{{ tab.label }}</span>
- <div class="underline"></div>
- </div>
- </div>
- <div class="perception-wrap">
- <equipment v-if="perceptionActive === 'device'"></equipment>
- <crop v-else></crop>
- </div>
- </div>
- </div>
- </template>
- </div>
- </div>
- </template>
- <script setup>
- import { ref ,onMounted} from "vue";
- import equipment from "./equipment.vue";
- import crop from "./crop.vue";
- onMounted(() => {
- fetchFarmList();
- });
- const fetchFarmList = () => {
- VE_API.warning.fetchFarmList().then(res => {
- if (res.code === 0 && res.data && res.data.length > 0) {
- farmList.value = res.data;
- } else {
- farmList.value = [];
- }
- });
- };
- // 底部 tabs 配置
- const tabs = [
- { key: "crop", label: "作物档案" },
- { key: "perception", label: "感知记录" },
- ];
- // 感知类型 tabs
- const perceptionTabs = [
- { key: "device", label: "设备感知" },
- { key: "crop", label: "作物感知" },
- ];
- const activeTab = ref("crop"); // 默认选中感知记录
- const perceptionActive = ref("device"); // 默认选中设备感知
- // 时间轴示例数据(后续可替换为接口数据)
- const timelineList = ref([
- { id: 1, date: "8/1", text: "水稻进入拔节期,水稻进入拔节期" },
- { id: 2, date: "8/1", text: "水稻进入拔节期,水稻进入拔节期" },
- { id: 3, date: "8/1", text: "水稻进入拔节期,水稻进入拔节期" },
- { id: 4, date: "8/1", text: "水稻进入拔节期,水稻进入拔节期" },
- { id: 5, date: "8/1", text: "水稻进入拔节期,水稻进入拔节期" },
- ]);
- const farmList = ref([]);
- const handleBack = () => {
- farmList.value = [
- { id: 1, name: "荔博园", area: "58亩", position: "广东省广州市***", owner: "张扬" },
- { id: 2, name: "荔博园", area: "58亩", position: "广东省广州市***", owner: "张扬" },
- { id: 3, name: "荔博园", area: "58亩", position: "广东省广州市***", owner: "张扬" },
- { id: 4, name: "荔博园", area: "58亩", position: "广东省广州市***", owner: "张扬" },
- { id: 5, name: "荔博园", area: "58亩", position: "广东省广州市***", owner: "张扬" },
- ];
- };
- const handleCropArchive = () => {
- // 作物档案逻辑
- };
- const handlePerceptionRecord = () => {
- // 感知记录逻辑
- };
- const handleFarmInfo = (item) => {
- farmList.value = [item];
- };
- </script>
- <style lang="scss" scoped>
- .farm-info-group {
- position: absolute;
- top: 0px;
- right: 0;
- width: 376px;
- height: 100%;
- background: #232323;
- border-radius: 4px;
- box-sizing: border-box;
- border: 1px solid rgba(255, 255, 255, 0.16);
- .info-header {
- display: flex;
- align-items: center;
- padding: 6px 14px;
- border-bottom: 1px solid rgba(255, 255, 255, 0.16);
- .back-btn {
- cursor: pointer;
- color: rgba(255, 255, 255, 0.55);
- }
- .title {
- flex: 1;
- display: flex;
- align-items: center;
- justify-content: center;
- gap: 8px;
- font-size: 18px;
- .title-icon {
- width: 19px;
- height: 13px;
- }
- }
- }
- .info-content {
- padding: 5px 10px;
- height: calc(100% - 168px);
- overflow-y: auto;
- .farm-info + .farm-info {
- margin-top: 12px;
- }
- .farm-info {
- display: flex;
- align-items: flex-start;
- gap: 12px;
- .lz-icon {
- border-radius: 6px;
- background: rgba(70, 70, 70, 0.26);
- img {
- width: 65px;
- height: 65px;
- padding: 7px;
- }
- }
- .info-right {
- font-size: 12px;
- color: #9f9f9f;
- .info-item {
- display: flex;
- align-items: center;
- line-height: 18px;
- gap: 6px;
- cursor: pointer;
- &.farm-code {
- font-weight: 700;
- font-size: 16px;
- margin-bottom: 4px;
- color: #ffffff;
- }
- .tags {
- display: flex;
- gap: 4px;
- margin-left: auto;
- .tag {
- padding: 1px 6px;
- border: 1px solid #ffd489;
- border-radius: 2px;
- color: #ffd489;
- font-size: 12px;
- font-weight: 400;
- }
- }
- }
- }
- }
- .tabs {
- display: flex;
- gap: 10px;
- margin-top: 12px;
- .tab-item {
- padding: 6px 32px;
- text-align: center;
- border-radius: 4px;
- cursor: pointer;
- color: #ffffff;
- background: rgba(166, 166, 166, 0.08);
- border: 1px solid transparent;
- &.active {
- color: #ffd489;
- background: rgba(255, 212, 137, 0.2);
- border: 1px solid #ffd489;
- }
- }
- }
- .tab-content {
- margin: 12px 0;
- height: calc(100% - 24px);
- overflow-y: auto;
- .timeline {
- padding-right: 12px;
- .timeline-item {
- display: flex;
- align-items: flex-start;
- font-size: 14px;
- color: #ffffff;
- line-height: 22px;
- & + .timeline-item {
- margin-top: 24px;
- }
- .timeline-left {
- width: 24px;
- display: flex;
- flex-direction: column;
- align-items: center;
- .dot {
- width: 6px;
- height: 6px;
- border-radius: 50%;
- background: #ffd489;
- margin-top: 6px;
- }
- .line {
- border-left: 1px dashed rgba(255, 212, 137, 0.6);
- margin-top: 4px;
- height: 40px;
- }
- }
- .timeline-right {
- padding-left: 8px;
- .date {
- color: #ffd489;
- font-weight: 500;
- margin-bottom: 2px;
- }
- .text {
- color: #d7d7d7;
- }
- }
- }
- }
- .perception-content {
- height: 100%;
- .perception-tabs {
- display: flex;
- align-items: flex-end;
- gap: 20px;
- margin-bottom: 12px;
- .perception-tab {
- color: #ffffff;
- cursor: pointer;
- .underline {
- margin-top: 6px;
- width: 56px;
- height: 2px;
- background: transparent;
- border-radius: 2px;
- }
- &.perception-tab--active {
- color: #ffd489;
- .underline {
- background: #ffd489;
- }
- }
- }
- }
- .perception-wrap {
- height: calc(100% - 40px);
- overflow-y: auto;
- }
- }
- }
- }
- }
- </style>
|