|
|
@@ -194,6 +194,8 @@ const router = useRouter();
|
|
|
const tabBarHeight = computed(() => store.state.home.tabBarHeight);
|
|
|
|
|
|
const DIAGNOSIS_GUIDE_STORAGE_KEY = "AGRI_FILE_DIAGNOSIS_REPORT_GUIDE";
|
|
|
+const ENTRY_FARM_DATA_KEY = "ENTRY_FARM_DATA";
|
|
|
+const CROP_ARCHIVE_KEY = "CROP_ARCHIVE_RECORDS";
|
|
|
const guideVisible = ref(false);
|
|
|
|
|
|
const defaultCover = require("@/assets/img/home/banner.png");
|
|
|
@@ -225,17 +227,43 @@ const navCards = [
|
|
|
},
|
|
|
];
|
|
|
|
|
|
-const zoneList = ref([
|
|
|
- { id: 1, name: "", count: 2, cover: defaultCover, longitude: 113.612409, latitude: 23.587036 },
|
|
|
- { id: 2, name: "", count: 2, cover: defaultCover, longitude: 113.615809, latitude: 23.586636 },
|
|
|
- { id: 3, name: "", count: 2, cover: defaultCover, longitude: 113.613609, latitude: 23.584436 },
|
|
|
- { id: 4, name: "", count: 2, cover: defaultCover, longitude: 113.615609, latitude: 23.585036 },
|
|
|
-]);
|
|
|
+/** 读取用户新增农场时选中的点位 */
|
|
|
+function readEntryFarmCoordinate() {
|
|
|
+ try {
|
|
|
+ const data = JSON.parse(localStorage.getItem(ENTRY_FARM_DATA_KEY) || "null");
|
|
|
+ if (Array.isArray(data?.coordinate) && data.coordinate.length === 2) {
|
|
|
+ return [Number(data.coordinate[0]), Number(data.coordinate[1])];
|
|
|
+ }
|
|
|
+ const point =
|
|
|
+ data?.point ||
|
|
|
+ localStorage.getItem("GROWTH_REPORT_MAP_POINT") ||
|
|
|
+ localStorage.getItem("selectedFarmPoint");
|
|
|
+ if (typeof point === "string" && /^POINT\s*\(/i.test(point.trim())) {
|
|
|
+ return util.wktCastGeom(point).getFirstCoordinate();
|
|
|
+ }
|
|
|
+ } catch {
|
|
|
+ // ignore
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+}
|
|
|
+
|
|
|
+function buildZoneList(coordinate = readEntryFarmCoordinate() || DEFAULT_CENTER) {
|
|
|
+ return [
|
|
|
+ {
|
|
|
+ id: 1,
|
|
|
+ name: "",
|
|
|
+ count: 2,
|
|
|
+ cover: defaultCover,
|
|
|
+ longitude: Number(coordinate[0]),
|
|
|
+ latitude: Number(coordinate[1]),
|
|
|
+ },
|
|
|
+ ];
|
|
|
+}
|
|
|
+
|
|
|
+const zoneList = ref(buildZoneList());
|
|
|
|
|
|
const albumList = ref([
|
|
|
- { id: 1, name: "", count: 0, cover: "" },
|
|
|
- { id: 2, name: "", count: 125, cover: defaultCover },
|
|
|
- { id: 3, name: "", count: 125, cover: defaultCover },
|
|
|
+ { id: 1, name: "", count: 125, cover: defaultCover },
|
|
|
]);
|
|
|
|
|
|
const reportCover = require("@/assets/img/common/sd-1.jpg");
|
|
|
@@ -300,11 +328,21 @@ const patrolList = ref([
|
|
|
},
|
|
|
]);
|
|
|
|
|
|
-const cropArchiveList = ref([
|
|
|
- { id: 1, date: "2025-04-18", zone_name: "", content: "" },
|
|
|
- { id: 2, date: "2025-04-18", zone_name: "", content: "" },
|
|
|
- { id: 3, date: "2025-04-10", zone_name: "", content: "" },
|
|
|
-]);
|
|
|
+const MOCK_CROP_ARCHIVE = [
|
|
|
+ { id: "mock-2", date: "2025-04-18", contentKey: "agriFile.cropArchiveAbnormal" },
|
|
|
+ { id: "mock-3", date: "2025-04-10", contentKey: "agriFile.cropArchiveMetric" },
|
|
|
+];
|
|
|
+
|
|
|
+const cropArchiveList = ref([]);
|
|
|
+
|
|
|
+function readCropArchiveAnswers() {
|
|
|
+ try {
|
|
|
+ const list = JSON.parse(localStorage.getItem(CROP_ARCHIVE_KEY) || "[]");
|
|
|
+ return Array.isArray(list) ? list : [];
|
|
|
+ } catch {
|
|
|
+ return [];
|
|
|
+ }
|
|
|
+}
|
|
|
|
|
|
const setMarkerEl = (id, el) => {
|
|
|
if (el) markerEls[id] = el;
|
|
|
@@ -312,6 +350,8 @@ const setMarkerEl = (id, el) => {
|
|
|
};
|
|
|
|
|
|
const getFarmCenter = () => {
|
|
|
+ const entryCoordinate = readEntryFarmCoordinate();
|
|
|
+ if (entryCoordinate) return entryCoordinate;
|
|
|
try {
|
|
|
const farm = JSON.parse(localStorage.getItem("selectedFarmData") || "{}");
|
|
|
const wkt = farm.wkt || farm.geom_wkt || farm.farm_location;
|
|
|
@@ -350,9 +390,19 @@ const bindZoneOverlays = () => {
|
|
|
});
|
|
|
};
|
|
|
|
|
|
+const syncZoneFromEntry = () => {
|
|
|
+ const coordinate = readEntryFarmCoordinate() || getFarmCenter();
|
|
|
+ const zoneName = zoneList.value[0]?.name || "";
|
|
|
+ zoneList.value = buildZoneList(coordinate).map((item) => ({
|
|
|
+ ...item,
|
|
|
+ name: zoneName,
|
|
|
+ }));
|
|
|
+};
|
|
|
+
|
|
|
const initAlbumMap = async () => {
|
|
|
await nextTick();
|
|
|
if (!mapContainer.value) return;
|
|
|
+ syncZoneFromEntry();
|
|
|
const center = getFarmCenter();
|
|
|
fileMap.initMap(`POINT(${center[0]} ${center[1]})`, mapContainer.value);
|
|
|
await nextTick();
|
|
|
@@ -384,11 +434,15 @@ const fillMockLabels = () => {
|
|
|
subject: t("agriFile.patrolSubject"),
|
|
|
issue: t("agriFile.patrolIssue"),
|
|
|
}));
|
|
|
- cropArchiveList.value = cropArchiveList.value.map((item, index) => ({
|
|
|
- ...item,
|
|
|
- zone_name: albumName,
|
|
|
- content: t(index % 2 === 0 ? "agriFile.cropArchiveMetric" : "agriFile.cropArchiveAbnormal"),
|
|
|
- }));
|
|
|
+ cropArchiveList.value = [
|
|
|
+ ...readCropArchiveAnswers(),
|
|
|
+ ...MOCK_CROP_ARCHIVE.map((item) => ({
|
|
|
+ id: item.id,
|
|
|
+ date: item.date,
|
|
|
+ zone_name: albumName,
|
|
|
+ content: t(item.contentKey),
|
|
|
+ })),
|
|
|
+ ];
|
|
|
};
|
|
|
|
|
|
const goAddZone = (type) => {
|