| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033 |
- <template>
- <div class="patrol-panel">
- <!-- 品种切换 -->
- <div class="variety-bar">
- <div class="variety-bar__tags">
- <div v-for="item in zoneList" :key="item.zone_id" class="variety-bar__tag"
- :class="{ active: item.zone_id === selectedZoneId }" @click="handleSelectZone(item)">
- {{ item.zone_name }}
- </div>
- </div>
- <div class="variety-bar__add" @click="goAddVariety">
- <el-icon size="10">
- <Plus />
- </el-icon>
- <span>新增品种</span>
- </div>
- </div>
- <!-- <div v-if="loading" class="patrol-loading">
- <span class="patrol-loading__spinner"></span>
- <span class="patrol-loading__text">加载中...</span>
- </div> -->
- <div v-loading="loading" element-loading-background="rgba(15, 15, 15, 0.55)" element-loading-text="加载中...">
- <div v-for="item in patrolList" :key="item.id" class="tracking-item" @click="goGrowthTrack(item)">
- <div class="tracking-item__header">
- <div class="tracking-item__header-left">
- <img class="tracking-item__header-icon" :src="item.headerIcon || periodIcon" alt="" />
- <span class="tracking-item__title van-ellipsis">
- {{ item.title }}
- </span>
- </div>
- <div v-if="item.level" class="tracking-item__level" :class="'level-' + item.level_num">
- <el-icon>
- <WarningFilled />
- </el-icon>
- <span>{{ item.level }}</span>
- </div>
- </div>
- <div class="tracking-item__body">
- <img class="tracking-item__thumb" :src="item.icon" alt="" />
- <div class="tracking-item__content">
- <div class="tracking-item__subject van-ellipsis">{{ item.subject }}</div>
- <div class="tracking-item__issue">{{ item.issue || item.desc }}</div>
- <div class="tracking-item__urgency"
- :class="`tracking-item__urgency--${item.urgencyTone || 'danger'}`">
- <img v-if="item.urgencyIcon" class="tracking-item__urgency-icon" :src="item.urgencyIcon"
- alt="" />
- <el-icon v-else>
- <Clock />
- </el-icon>
- <span>{{ item.urgencyText || "建议 24 小时内处理" }}</span>
- </div>
- </div>
- </div>
- <div class="tracking-item__footer">
- <div class="tracking-item__actions">
- <div class="tracking-item__action" @click.stop="handleShare(item)">
- <Icon size="14" color="rgba(255,255,255,0.75)" name="share" />
- <span>{{ t("agriFile.forward") }}</span>
- </div>
- <span class="tracking-item__divider"></span>
- <div class="tracking-item__action" @click.stop="handleUploadClick(item)">
- <el-icon>
- <Camera />
- </el-icon>
- <span>上传巡园照片</span>
- </div>
- </div>
- <div class="tracking-item__detail-btn" @click.stop="goGrowthTrack(item)">
- 进入详情 <el-icon>
- <ArrowRightBold />
- </el-icon>
- </div>
- </div>
- </div>
- <div class="no-data-text" v-if="patrolList.length == 0">
- <div>不在作物的种植周期内</div>
- <div>暂无巡园记录</div>
- </div>
- </div>
- <div class="crop-archive">
- <!-- <div class="crop-archive__title">{{ t("agriFile.cropArchive") }}</div> -->
- <PhenologyTrackTimelineItem theme="dark" :list="cropArchiveList" />
- </div>
- <album-upload-popup v-model:show="showUploadPopup" @confirm="handleUploadConfirm" />
- <tip-popup class="restore-planting-success-popup" :zIndex="20000" v-model:show="showSuccessPopup" type="executeSuccess" text="您已上传成功" text2="诊断报告正在生成,请稍后..." hideBtn>
- <template #footer>
- <div class="bottom-btn-container">
- <div class="bottom-btn primary-btn" @click="handleComplete">完成</div>
- </div>
- </template>
- </tip-popup>
- </div>
- </template>
- <script setup>
- import { nextTick, onActivated, onMounted, ref } from "vue";
- import { useRoute, useRouter } from "vue-router";
- import { Icon } from "vant";
- import { ElMessage } from "element-plus";
- import { Camera, Clock, Plus, WarningFilled } from "@element-plus/icons-vue";
- import { useI18n } from "@/i18n";
- import { base_img_url2 } from "@/api/config";
- import { resolvePairedFarmZone } from "@/utils/selectedFarm";
- import PhenologyTrackTimelineItem from "@/components/pageComponents/PhenologyTrackTimelineItem.vue";
- import albumUploadPopup from "./albumUploadPopup.vue";
- import tipPopup from "@/components/popup/tipPopup.vue";
- import wx from "weixin-js-sdk";
- const { t } = useI18n();
- const route = useRoute();
- const router = useRouter();
- const PATROL_ICON = require("@/assets/img/common/empty-bg.png");
- const periodIcon = require("@/assets/img/agricultural/period.png");
- const lightningIcon = require("@/assets/img/agricultural/lightning.png");
- const soilIcon = require("@/assets/img/agricultural/soil.png");
- /** 长势:最佳窗口(资源文件名 clock,实际为日历) */
- const calendarUrgencyIcon = require("@/assets/img/agricultural/clock.png");
- /** 土壤:含水率提示 */
- const waterUrgencyIcon = require("@/assets/img/agricultural/water.png");
- /** 接口返回的图片可能是 CDN 相对路径 */
- const resolveTaskImage = (url) => {
- if (!url) return "";
- const text = String(url).trim();
- if (!text) return "";
- if (/^https?:\/\//i.test(text)) return text;
- return base_img_url2 + text.replace(/^\//, "");
- };
- // ---------- 页面状态 ----------
- const zoneList = ref([]);
- const selectedZoneId = ref(null);
- const selectedZoneName = ref("");
- /** 物候卡片占位(接口无数据 / 请求失败时兜底展示) */
- const buildGrowthPatrolMock = () => ({
- id: "growth-mock",
- type: "growth",
- theme: "blue",
- level: null,
- title: t("agriFile.patrolGrowthTitle"),
- zone: selectedZoneName.value || t("agriFile.zoneOne"),
- subject: t("agriFile.patrolSubject"),
- issue: t("agriFile.patrolIssue"),
- desc: "",
- urgencyText: "最佳窗口 --",
- urgencyTone: "success",
- urgencyIcon: calendarUrgencyIcon,
- headerIcon: periodIcon,
- icon: PATROL_ICON,
- });
- /** 默认组成:仅物候占位;异常 / 土壤根系卡由接口数据决定,无数据不占位 */
- const buildDefaultPatrolList = () => [buildGrowthPatrolMock()];
- const patrolList = ref(buildDefaultPatrolList());
- /** 巡园接口返回前的加载态 */
- const loading = ref(false);
- const cropArchiveList = ref([]);
- const showUploadPopup = ref(false);
- const showSuccessPopup = ref(false);
- const uploadZoneId = ref("");
- /** 当前上传来源卡片类型:growth 走相册接口;abnormal / soil 走巡检接口 */
- const uploadCardType = ref("");
- /** 范围校验进行中,避免重复点击触发多次跳转 */
- const uploadChecking = ref(false);
- /** 新增品种前校验范围,避免重复跳转 */
- const addVarietyChecking = ref(false);
- // ---------- 工具函数 ----------
- function formatToday() {
- const d = new Date();
- const y = d.getFullYear();
- const m = String(d.getMonth() + 1).padStart(2, "0");
- const day = String(d.getDate()).padStart(2, "0");
- return `${y}-${m}-${day}`;
- }
- /** 农场品类编码,接口 crop_type */
- const resolveCropType = (farm = getSelectedFarm()) =>
- farm.category_code || farm.categorycode || farm.crop_code || farm.crop_type || "";
- /**
- * 新接口按分块下发的单条巡园任务(pheno / abnormal / soil_root)→ 巡园卡片
- * 字段直接来自 data.pheno / data.abnormal / data.soil_root;无对应分块则不展示该项
- */
- const mapSectionToPatrol = (section = {}, type, ctx = {}) => {
- const isAbnormal = type === "abnormal";
- const isSoil = type === "soil";
- const isGrowth = type === "growth";
- const title = isSoil
- ? "土壤根系感知"
- : isGrowth
- ? t("agriFile.patrolGrowthTitle")
- : t("agriFile.patrolAbnormalTitle");
- const subject =
- section.title ||
- section.interact_title ||
- section.interaction_title ||
- section.pheno_name ||
- "";
- const issue =
- section.interact_theme ||
- section.interaction_theme ||
- section.interaction_reason
- "";
- const level = section.level || (isSoil ? "一级" : "");
- const urgencyText =
- section.action_hint ||
- (isSoil
- ? "土壤含水率偏高 · 已持续 5 天"
- : isGrowth
- ? "最佳窗口待确认"
- : "建议 24 小时内处理");
- const urgencyTone = isSoil ? "warn" : isGrowth ? "success" : "danger";
- const urgencyIcon = isSoil ? waterUrgencyIcon : isGrowth ? calendarUrgencyIcon : "";
- const headerIcon = isSoil ? soilIcon : isGrowth ? periodIcon : lightningIcon;
- const icon = resolveTaskImage(section.image_url || section.pic_url || section.guide_url) || PATROL_ICON;
- const zoneId = section.zone_id ?? ctx.zoneId ?? selectedZoneId.value;
- return {
- id: section.type_code ? `${section.type_code}:${zoneId}` : `${type}:${zoneId}`,
- type,
- theme: "blue",
- level,
- level_num: section.level_num,
- title,
- subject,
- issue,
- desc: "",
- urgencyText,
- urgencyTone,
- urgencyIcon,
- headerIcon,
- icon,
- zone: ctx.zone || selectedZoneName.value || "",
- zoneId,
- interactCode: section.interact_code || "",
- fwCode: section.fw_code || "",
- taskKey: section.type_code || type,
- status: section.status || "",
- raw: section,
- };
- };
- /**
- * 一次接口返回 → 巡园卡片:物候(pheno) → 异常(abnormal) → 土壤根系(soil_root)
- * pheno / abnormal 有数据才展示对应卡片;soil_root 缺失时兜底写死占位
- */
- const buildPatrolList = (data = {}) => {
- const zoneId = data.zone_id ?? selectedZoneId.value;
- const zone = selectedZoneName.value || "";
- const ctx = { zoneId, zone, data };
- const list = [];
- if (data.pheno) list.push(mapSectionToPatrol(data.pheno, "growth", ctx));
- if (data.abnormal) list.push(mapSectionToPatrol(data.abnormal, "abnormal", ctx));
- // 土壤根系:接口字段为 soil_root(type_code=soil_root),缺失则不显示
- if (data.soil_root) list.push(mapSectionToPatrol(data.soil_root, "soil", ctx));
- return list;
- };
- const mapPhenoRecordToArchive = (item, index, zoneName) => {
- // 物候记录用 enter_date,异常记录只有 trigger_date
- const date = item.enter_date || item.trigger_date || "";
- return {
- id: [item.zone_id, item.type, date, item.period_code || item.fw_code, index]
- .filter((v) => v != null && v !== "")
- .join("_"),
- date,
- zone_name: item.zone_name || zoneName || "",
- content: item.sentence || (item.period_name ? `到达 ${item.period_name}` : ""),
- period_code: item.period_code,
- period_name: item.period_name,
- shoot_type: item.shoot_type,
- zone_id: item.zone_id,
- crop_code: item.crop_code,
- fw_code: item.fw_code,
- type: item.type,
- };
- };
- const getSelectedFarm = () => {
- try {
- return JSON.parse(localStorage.getItem("selectedFarmData") || "{}");
- } catch {
- return {};
- }
- };
- const getSelectedFarmId = () => {
- const stored = localStorage.getItem("selectedFarmId");
- if (stored != null && stored !== "") {
- return Number(stored);
- }
- const farm = getSelectedFarm();
- const id = farm.farm_id ?? farm.id;
- return id != null && id !== "" ? Number(id) : null;
- };
- /** 切换农场 / 分区、请求失败时清空接口数据,回退为占位卡片 */
- const resetPatrolList = () => {
- patrolList.value = buildDefaultPatrolList();
- };
- // ---------- 业务逻辑:加载 ----------
- const applySelectedZone = (zone) => {
- selectedZoneId.value = zone?.zone_id ?? null;
- selectedZoneName.value = zone?.zone_name || "";
- };
- /** 记录上次拉分区的农场,切农场时丢弃旧 selectedZoneId */
- let lastZonesFarmId = null;
- const fetchZones = async () => {
- const farmId = getSelectedFarmId();
- if (farmId == null) {
- lastZonesFarmId = null;
- zoneList.value = [];
- applySelectedZone(null);
- return;
- }
- // 切农场后旧 zone 不属于新农场,先清空再拉,避免上传校验错配
- if (lastZonesFarmId !== farmId) {
- applySelectedZone(null);
- lastZonesFarmId = farmId;
- }
- try {
- const res = await VE_API.questionnaire.getZones({ farm_id: farmId });
- const zones = Array.isArray(res?.data?.zones) ? res.data.zones : [];
- // zoneList.value = zones.reverse();
- zoneList.value = zones;
- // 同农场内优先沿用当前选中;否则默认第一个
- const matched = zones.find((z) => z.zone_id === selectedZoneId.value);
- applySelectedZone(matched || zoneList.value[0] || null);
- } catch (e) {
- console.warn("[patrolPanel] getZones failed", e);
- zoneList.value = [];
- applySelectedZone(null);
- }
- };
- /** 首页巡园要点:物候 / 异常 / 土壤由 getTypesTask 一次返回 */
- const fetchTypesTask = async () => {
- const farm = getSelectedFarm();
- const farmId = getSelectedFarmId();
- const zoneId = selectedZoneId.value;
- const cropType = resolveCropType(farm);
- if (farmId == null || zoneId == null || zoneId === "" || !cropType) {
- resetPatrolList();
- return;
- }
- loading.value = true;
- try {
- const res = await VE_API.pheno.getTypesTask({
- crop_type: cropType,
- farm_id: farmId,
- zone_id: zoneId,
- calc_date: formatToday(),
- });
- if (res?.code !== 200) {
- resetPatrolList();
- loading.value = false;
- return;
- }
- patrolList.value = buildPatrolList(res?.data || {});
- loading.value = false;
- } catch (e) {
- console.warn("[patrolPanel] getTypesTask failed", e);
- resetPatrolList();
- loading.value = false;
- }
- };
- const fetchCropArchive = async () => {
- const farm = getSelectedFarm();
- const query = {
- farm_id: farm.farm_id ?? farm.id,
- crop_code: farm.category_code,
- };
- if (!farm.farm_id) return
- try {
- const res = await VE_API.entry.getPhenoRecord(query);
- if (res?.code !== 200) {
- cropArchiveList.value = [];
- return;
- }
- const data = res?.data || {};
- const zones = Array.isArray(data.zones) ? data.zones : [];
- // 新结构:data.zones[].records 为各分区的物候 / 异常记录
- let cursor = 0;
- const list = [];
- for (const zone of zones) {
- const records = Array.isArray(zone.records) ? zone.records : [];
- const zoneName = zone.zone_name || zone.crop_variety || String(zone.zone_id ?? "");
- for (const item of records) {
- list.push(mapPhenoRecordToArchive(item, cursor, zoneName));
- cursor += 1;
- }
- }
- cropArchiveList.value = list.sort((a, b) =>
- String(b.date).localeCompare(String(a.date))
- );
- } catch (e) {
- console.warn("[patrolPanel] getPhenoRecord failed", e);
- cropArchiveList.value = [];
- }
- };
- /** 按当前选中品种刷新巡园卡片(作物档案按农场维度,切品种不重拉) */
- const reloadBySelectedZone = () => {
- resetPatrolList();
- fetchTypesTask();
- };
- const loadPatrolData = async () => {
- // 先清掉上一农场的任务数据,避免切换时残留
- // resetPatrolList();
- await fetchZones();
- fetchTypesTask();
- fetchCropArchive();
- };
- // ---------- 事件处理 ----------
- const handleSelectZone = (zone) => {
- if (!zone || zone.zone_id === selectedZoneId.value) return;
- applySelectedZone(zone);
- reloadBySelectedZone();
- };
- /**
- * 新增品种前校验当前选中品种是否已勾画范围(同 albumPanel checkZoneRange):
- * 已勾画 → 直接进新增分区;未勾画 → 先 type=farm 画范围,
- * 画完后 addZone 会 ElMessage「勾画完成」并继续进 type=region&isSuccessPopup=1
- */
- const goAddVariety = async () => {
- if (addVarietyChecking.value) return;
- const goRegionAdd = () => {
- router.push({
- path: "/add_zone",
- query: { type: "region", isSuccessPopup: "1" },
- });
- };
- const zoneId = selectedZoneId.value;
- if (zoneId == null || zoneId === "") {
- goRegionAdd();
- return;
- }
- addVarietyChecking.value = true;
- try {
- if (await hasZoneRange(zoneId)) {
- goRegionAdd();
- return;
- }
- const varietyName = selectedZoneName.value || "当前品类";
- // ElMessage.warning(`请先勾画「${varietyName}」的种植范围,完成后再新增分区`);
- ElMessage({
- message: `请先勾画「${varietyName}」的种植范围,\n完成后再新增品种`,
- type: "warning",
- customClass: "restore-planting-message",
- zIndex: 40000,
- });
- setTimeout(() => {
- router.push({
- path: "/add_zone",
- query: {
- type: "farm",
- continueAddVariety: "1",
- zoneId,
- },
- });
- }, 800);
- } finally {
- addVarietyChecking.value = false;
- }
- };
- /** 卡片 id 为任务标识,详情 / 上传 / 分享统一使用分区 id */
- const resolveCardZoneId = (item) => item?.zoneId ?? selectedZoneId.value ?? item?.id ?? "";
- const goGrowthTrack = (item) => {
- const type = item?.type;
- const zoneId = resolveCardZoneId(item);
- const path =
- type === "soil"
- ? "/soil_root_track"
- : type === "abnormal"
- ? "/abnormal_track"
- : "/growth_track";
- router.push({
- path,
- query: {
- id: zoneId,
- ...(zoneId !== "" ? { zoneId } : {}),
- pageName: item.title || "详情",
- },
- });
- };
- const handleShare = (item) => {
- const type = item?.type;
- const zoneId = resolveCardZoneId(item);
- let targetUrl;
- let pageName;
- let coverImg;
- if (type === "soil") {
- targetUrl = "soil_root_track";
- pageName = t("agriFile.patrolSoilTitle");
- coverImg = "https://birdseye-img.sysuimars.com/farm-h5/growth_cover.png";
- } else if (type === "abnormal") {
- targetUrl = "abnormal_track";
- pageName = t("agriFile.patrolAbnormalTitle");
- coverImg = "https://birdseye-img.sysuimars.com/farm-h5/abnormal_cover.png";
- } else {
- targetUrl = "growth_track";
- pageName = t("agriFile.patrolGrowthTitle");
- coverImg = "https://birdseye-img.sysuimars.com/farm-h5/growth_cover.png";
- }
- const shareFarmId = getSelectedFarmId();
- const query = {
- askInfo: { title: "转发巡园要点", content: "是否分享给好友" },
- shareText: item?.issue || "巡园要点",
- targetUrl,
- paramsPage: JSON.stringify({
- id: zoneId,
- fromShare: 1,
- ...(zoneId !== "" ? { zoneId } : {}),
- ...(shareFarmId != null && shareFarmId !== "" ? { farmId: shareFarmId } : {}),
- pageName,
- }),
- imageUrl: coverImg,
- };
- wx.miniProgram.navigateTo({
- url: `/pages/subPages/share_page/index?pageParams=${JSON.stringify(query)}&type=sharePage`,
- });
- };
- /** status=1 表示已勾画种植范围;信息不全 / 校验异常时不拦截上传 */
- const hasZoneRange = async (zoneId) => {
- const farmId = getSelectedFarmId();
- if (farmId == null || farmId === "" || zoneId == null || zoneId === "") return true;
- // 分区必须落在当前农场分区列表内,防止卡片残留旧 zoneId
- const belongsToFarm = zoneList.value.some((z) => String(z.zone_id) === String(zoneId));
- if (!belongsToFarm) return false;
- try {
- const res = await VE_API.questionnaire.checkZoneRange({
- farm_id: farmId,
- zone_id: zoneId,
- });
- return Number(res?.data?.status) === 1;
- } catch (e) {
- console.warn("[patrolPanel] checkZoneRange failed", e);
- return true;
- }
- };
- /**
- * 上传前校验地块范围:
- * 已勾画 → 直接弹上传;未勾画 → 先去 /add_zone 画范围,
- * 画好后 addZone 带 showUpload=1 回跳 /agri_file,由 tryContinueUpload 恢复上传弹窗
- */
- const handleUploadClick = async (item) => {
- if (uploadChecking.value) return;
- const zoneId = resolveCardZoneId(item);
- uploadZoneId.value = zoneId;
- uploadCardType.value = item?.type || "";
- uploadChecking.value = true;
- try {
- if (await hasZoneRange(zoneId)) {
- showUploadPopup.value = true;
- return;
- }
- router.push({
- path: "/add_zone",
- query: {
- type: "farm",
- targetUrl: "/agri_file",
- ...(zoneId !== "" && zoneId != null
- ? { zoneId, trackId: zoneId }
- : {}),
- },
- });
- } finally {
- uploadChecking.value = false;
- }
- };
- /** 勾画完成返回(showUpload=1):恢复上传弹窗并清掉标记 */
- const tryContinueUpload = () => {
- if (route.query.showUpload !== "1") return;
- uploadZoneId.value =
- route.query.id || uploadZoneId.value || selectedZoneId.value || "";
- nextTick(() => {
- showUploadPopup.value = true;
- });
- const { showUpload, ...restQuery } = route.query;
- router.replace({ path: route.path, query: restQuery });
- };
- /** 异常态势 / 土壤根系:与 abnormalTrack 相同,走巡检上传 */
- const isInspectUploadType = (type) => type === "abnormal" || type === "soil";
- const handleUploadConfirm = async ({ images, date } = {}) => {
- if (isInspectUploadType(uploadCardType.value)) {
- const imageList = (Array.isArray(images) ? images : [])
- .filter(Boolean)
- .map((url) => resolveTaskImage(url));
- if (!imageList.length) {
- ElMessage.warning("请先上传照片");
- return;
- }
- const zoneId = uploadZoneId.value || selectedZoneId.value;
- const { farmId, zoneId: pairedZoneId } = await resolvePairedFarmZone(zoneId);
- if (farmId == null || pairedZoneId == null || pairedZoneId === "") {
- ElMessage.warning("当前农场与分区不匹配,请返回后重试");
- return;
- }
- try {
- const res = await VE_API.pheno.uploadAbnormalPhoto({
- farm_id: farmId,
- zone_id: pairedZoneId,
- images: imageList,
- });
- if (res?.code === 200) {
- showSuccessPopup.value = true;
- return;
- }
- ElMessage.error(res?.msg || "上传失败,请稍后再试");
- } catch {
- ElMessage.error("上传失败,请稍后再试");
- }
- return;
- }
- const cloud_url = Array.isArray(images) ? images : [];
- if (!cloud_url.length) {
- ElMessage.warning("请先上传照片");
- return;
- }
- const farm = getSelectedFarm();
- try {
- const res = await VE_API.questionnaire.uploadImages({
- cloud_url,
- farm_id: farm.farm_id ?? farm.id ?? "",
- zone_id: uploadZoneId.value || selectedZoneId.value || "",
- category_code: farm.category_code || "",
- zone_name: selectedZoneName.value || farm.variety_name || "",
- create_time: date,
- });
- if (res?.code === 200) {
- showSuccessPopup.value = true;
- return;
- }
- ElMessage.error(res?.msg || "上传失败,请稍后再试");
- } catch {
- ElMessage.error("上传失败,请稍后再试");
- }
- };
- const handleComplete = () => {
- showSuccessPopup.value = false;
- };
- // ---------- 生命周期 ----------
- onMounted(loadPatrolData);
- onActivated(() => {
- loadPatrolData();
- tryContinueUpload();
- });
- defineExpose({
- fetchTypesTask,
- fetchCropArchive,
- loadPatrolData,
- });
- </script>
- <style lang="scss" scoped>
- .patrol-panel {
- // padding-top: 8px;
- .no-data-text {
- text-align: center;
- padding-top: 40px;
- font-size: 14px;
- color: #A8A094;
- display: flex;
- flex-direction: column;
- gap: 4px;
- }
- .crop-archive {
- margin-top: 16px;
- }
- .variety-bar {
- display: flex;
- align-items: center;
- justify-content: space-between;
- gap: 12px;
- margin-bottom: 12px;
- &__tags {
- display: flex;
- align-items: center;
- flex-wrap: nowrap;
- gap: 16px;
- flex: 1;
- min-width: 0;
- overflow-x: auto;
- -webkit-overflow-scrolling: touch;
- scrollbar-width: none;
- &::-webkit-scrollbar {
- display: none;
- }
- }
- &__tag {
- position: relative;
- flex: none;
- white-space: nowrap;
- padding: 4px 0 8px;
- color: rgba(255, 255, 255, 0.35);
- font-size: 14px;
- line-height: 20px;
- &.active {
- color: #ffd489;
- font-weight: 500;
- &::after {
- content: "";
- position: absolute;
- left: 50%;
- bottom: 0;
- transform: translateX(-50%);
- width: 100%;
- height: 2px;
- border-radius: 2px;
- background: #ffd489;
- }
- }
- }
- &__add {
- flex: none;
- display: flex;
- align-items: center;
- gap: 2px;
- height: 28px;
- padding: 0 10px;
- border-radius: 14px;
- border: 1px solid rgba(255, 255, 255, 0.1);
- background: rgba(255, 255, 255, 0.06);
- color: rgba(255, 255, 255, 0.8);
- font-size: 12px;
- box-sizing: border-box;
- }
- }
- .patrol-loading {
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- gap: 12px;
- padding: 64px 0;
- color: rgba(255, 255, 255, 0.6);
- font-size: 13px;
- letter-spacing: 1px;
- &__spinner {
- width: 28px;
- height: 28px;
- border-radius: 50%;
- border: 3px solid rgba(255, 255, 255, 0.15);
- border-top-color: #ffd489;
- animation: patrol-spin 0.8s linear infinite;
- }
- }
- .tracking-item {
- width: 100%;
- margin-bottom: 12px;
- padding: 10px 8px 8px 12px;
- border-radius: 12px;
- border: 1px solid rgba(255, 255, 255, 0.1);
- background: linear-gradient(180deg, #1A191D 0%, #121216 100%);
- box-sizing: border-box;
- &:last-of-type {
- margin-bottom: 0;
- }
- &__header {
- display: flex;
- align-items: center;
- justify-content: space-between;
- gap: 8px;
- padding-bottom: 10px;
- border-bottom: 1px solid rgba(255, 255, 255, 0.08);
- }
- &__header-left {
- display: flex;
- align-items: center;
- gap: 6px;
- min-width: 0;
- }
- &__header-icon {
- width: 16px;
- height: 16px;
- flex-shrink: 0;
- object-fit: contain;
- }
- &__title {
- color: rgba(255, 255, 255, 0.9);
- font-size: 14px;
- font-weight: 500;
- line-height: 20px;
- }
- &__level {
- flex-shrink: 0;
- display: flex;
- align-items: center;
- gap: 3px;
- height: 22px;
- padding: 0 8px;
- border-radius: 11px;
- background: rgba(126, 35, 33, 0.2);
- border: 1px solid rgba(201, 53, 50, 0.41);
- color: #FFA1A0;
- font-size: 12px;
- box-sizing: border-box;
- &.level-1 {
- border-color: rgba(255, 212, 137, 0.41);
- background-color: rgba(255, 212, 137, 0.16);
- color: #FFD489;
- }
- &.level-2 {
- border-color: rgba(255, 127, 20, 0.4);
- background-color: rgba(255, 127, 20, 0.18);
- color: #FF9B47;
- }
- &.level-3 {
- border-color: rgba(126, 35, 33, 0.2);
- background-color: rgba(126, 35, 33, 0.2);
- color: #FF7D7B;
- }
- .el-icon {
- font-size: 12px;
- }
- }
- &__body {
- display: flex;
- gap: 10px;
- padding: 12px 0;
- }
- &__thumb {
- width: 96px;
- height: 96px;
- flex-shrink: 0;
- border-radius: 8px;
- object-fit: cover;
- background: rgba(255, 255, 255, 0.06);
- }
- &__content {
- flex: 1;
- min-width: 0;
- display: flex;
- flex-direction: column;
- justify-content: space-around;
- gap: 4px;
- }
- &__subject {
- color: #fff;
- font-size: 16px;
- line-height: 24px;
- }
- &__issue {
- color: rgba(255, 255, 255, 0.6);
- font-size: 12px;
- line-height: 18px;
- display: -webkit-box;
- -webkit-box-orient: vertical;
- -webkit-line-clamp: 2;
- overflow: hidden;
- word-break: break-all;
- }
- &__urgency {
- display: flex;
- align-items: center;
- gap: 4px;
- margin-top: 2px;
- font-size: 12px;
- .el-icon {
- font-size: 13px;
- }
- &--success {
- color: #85a53e;
- }
- &--danger {
- color: #ff8f8f;
- }
- &--warn {
- color: #ffd489;
- }
- }
- &__urgency-icon {
- width: 14px;
- height: 14px;
- flex-shrink: 0;
- object-fit: contain;
- }
- &__footer {
- display: flex;
- align-items: center;
- justify-content: space-between;
- gap: 8px;
- }
- &__actions {
- display: flex;
- align-items: center;
- gap: 10px;
- min-width: 0;
- }
- &__action {
- display: flex;
- align-items: center;
- gap: 4px;
- color: rgba(255, 255, 255, 0.75);
- font-size: 12px;
- line-height: 16px;
- white-space: nowrap;
- .el-icon {
- font-size: 14px;
- }
- }
- &__divider {
- width: 1px;
- height: 12px;
- background: rgba(255, 255, 255, 0.16);
- flex-shrink: 0;
- }
- &__detail-btn {
- flex-shrink: 0;
- // height: 32px;
- // line-height: 32px;
- padding: 7px 10px 8px 10px;
- display: flex;
- align-items: center;
- justify-content: center;
- border-radius: 24px;
- background: linear-gradient(90deg, #FFEBC9 0%, #FFCA6D 100%);
- color: #000;
- font-size: 12px;
- font-weight: 500;
- }
- }
- }
- .bottom-btn-container {
- display: flex;
- justify-content: space-between;
- gap: 12px;
- width: 100%;
- .bottom-btn {
- padding: 0 25px;
- border-radius: 4px;
- font-size: 16px;
- height: 40px;
- line-height: 40px;
- box-sizing: border-box;
- font-weight: 500;
- text-align: center;
- &.primary-btn {
- flex: 1;
- background: linear-gradient(135deg, #FFEBC9 0%, #FFCA6D 100%);
- color: #1A1408;
- }
- }
- }
- @keyframes patrol-spin {
- to {
- transform: rotate(360deg);
- }
- }
- </style>
- <style lang="scss">
- .restore-planting-success-popup {
- &.tip-popup {
- z-index: 20000 !important;
- }
- }
- .el-message.restore-planting-message {
- z-index: 40000 !important;
- white-space: pre-line;
- &.el-message--warning .el-message__content {
- width: max-content;
- line-height: 19px;
- }
- }
- </style>
|