|
@@ -467,13 +467,56 @@ const patrolIcon = require("@/assets/img/report/wh-icon.png");
|
|
|
/** 巡园要点列表:接口 data 原样 push,字段在模板自行对接 */
|
|
/** 巡园要点列表:接口 data 原样 push,字段在模板自行对接 */
|
|
|
const patrolList = ref([]);
|
|
const patrolList = ref([]);
|
|
|
|
|
|
|
|
-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([]);
|
|
const cropArchiveList = ref([]);
|
|
|
|
|
|
|
|
|
|
+// function resolveUserTel() {
|
|
|
|
|
+// try {
|
|
|
|
|
+// const entry = JSON.parse(localStorage.getItem(ENTRY_FARM_DATA_KEY) || "null");
|
|
|
|
|
+// if (entry?.phone) return String(entry.phone).trim();
|
|
|
|
|
+// } catch {
|
|
|
|
|
+// // ignore
|
|
|
|
|
+// }
|
|
|
|
|
+// try {
|
|
|
|
|
+// const userInfo = JSON.parse(localStorage.getItem("localUserInfo") || "{}");
|
|
|
|
|
+// return String(userInfo.tel || userInfo.phone || userInfo.mobile || "").trim();
|
|
|
|
|
+// } catch {
|
|
|
|
|
+// return "";
|
|
|
|
|
+// }
|
|
|
|
|
+// }
|
|
|
|
|
+
|
|
|
|
|
+function formatPhenophaseDate(value) {
|
|
|
|
|
+ if (!value) return "";
|
|
|
|
|
+ const text = String(value).trim();
|
|
|
|
|
+ const iso = text.match(/(\d{4})-(\d{2})-(\d{2})/);
|
|
|
|
|
+ if (iso) return `${iso[1]}-${iso[2]}-${iso[3]}`;
|
|
|
|
|
+ const d = new Date(text);
|
|
|
|
|
+ if (Number.isNaN(d.getTime())) return "";
|
|
|
|
|
+ return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, "0")}-${String(d.getDate()).padStart(2, "0")}`;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+/** get_phenophase_info → 作物档案时间轴 */
|
|
|
|
|
+function mapPhenophaseInfoToArchive(list) {
|
|
|
|
|
+ const cropName = resolveSelectedCropName();
|
|
|
|
|
+ const rows = Array.isArray(list) ? list : [];
|
|
|
|
|
+ const filtered = cropName
|
|
|
|
|
+ ? rows.filter((item) => !item?.crop_category_name || item.crop_category_name === cropName)
|
|
|
|
|
+ : rows;
|
|
|
|
|
+ const source = filtered.length ? filtered : rows;
|
|
|
|
|
+ return source
|
|
|
|
|
+ .map((item, index) => ({
|
|
|
|
|
+ id: item?.phenophase_code
|
|
|
|
|
+ ? `${item.phenophase_code}-${item.start_time || index}`
|
|
|
|
|
+ : `pheno-${index}`,
|
|
|
|
|
+ date: formatPhenophaseDate(item?.start_time) || formatPhenophaseDate(item?.sentence),
|
|
|
|
|
+ zone_name: item?.crop_category_name || cropName || "",
|
|
|
|
|
+ content: item?.sentence || item?.phenophase_name || "",
|
|
|
|
|
+ phenophase_code: item?.phenophase_code,
|
|
|
|
|
+ phenophase_name: item?.phenophase_name,
|
|
|
|
|
+ }))
|
|
|
|
|
+ .filter((item) => item.date && item.content)
|
|
|
|
|
+ .sort((a, b) => String(b.date).localeCompare(String(a.date)));
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
function readCropArchiveAnswers() {
|
|
function readCropArchiveAnswers() {
|
|
|
try {
|
|
try {
|
|
|
const list = JSON.parse(localStorage.getItem(CROP_ARCHIVE_KEY) || "[]");
|
|
const list = JSON.parse(localStorage.getItem(CROP_ARCHIVE_KEY) || "[]");
|
|
@@ -483,6 +526,25 @@ function readCropArchiveAnswers() {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+async function fetchCropArchiveList() {
|
|
|
|
|
+ const tel = resolveUserTel();
|
|
|
|
|
+ if (!tel) {
|
|
|
|
|
+ cropArchiveList.value = readCropArchiveAnswers();
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ try {
|
|
|
|
|
+ const res = await VE_API.questionnaire.getPhenophaseInfo({ tel });
|
|
|
|
|
+ if (res?.code !== 200) {
|
|
|
|
|
+ cropArchiveList.value = readCropArchiveAnswers();
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ const apiList = mapPhenophaseInfoToArchive(res.data);
|
|
|
|
|
+ cropArchiveList.value = [...readCropArchiveAnswers(), ...apiList];
|
|
|
|
|
+ } catch {
|
|
|
|
|
+ cropArchiveList.value = readCropArchiveAnswers();
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
const setMarkerEl = (id, el) => {
|
|
const setMarkerEl = (id, el) => {
|
|
|
if (el) markerEls[id] = el;
|
|
if (el) markerEls[id] = el;
|
|
|
else delete markerEls[id];
|
|
else delete markerEls[id];
|
|
@@ -562,15 +624,12 @@ const fillMockLabels = () => {
|
|
|
const cropName = resolveSelectedCropName();
|
|
const cropName = resolveSelectedCropName();
|
|
|
zoneList.value = zoneList.value.map((item) => ({ ...item, name: cropName }));
|
|
zoneList.value = zoneList.value.map((item) => ({ ...item, name: cropName }));
|
|
|
albumList.value = albumList.value.map((item) => ({ ...item, name: cropName }));
|
|
albumList.value = albumList.value.map((item) => ({ ...item, name: cropName }));
|
|
|
- cropArchiveList.value = [
|
|
|
|
|
- ...readCropArchiveAnswers(),
|
|
|
|
|
- ...MOCK_CROP_ARCHIVE.map((item) => ({
|
|
|
|
|
- id: item.id,
|
|
|
|
|
- date: item.date,
|
|
|
|
|
- zone_name: cropName,
|
|
|
|
|
- content: t(item.contentKey),
|
|
|
|
|
- })),
|
|
|
|
|
- ];
|
|
|
|
|
|
|
+ reportList.value = reportList.value.map((item) => ({
|
|
|
|
|
+ ...item,
|
|
|
|
|
+ title: t("agriFile.reportTitle"),
|
|
|
|
|
+ desc: t("agriFile.reportDesc"),
|
|
|
|
|
+ date: t("agriFile.reportDate"),
|
|
|
|
|
+ }));
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -645,6 +704,7 @@ async function loadPatrolContent() {
|
|
|
await fetchPatrolAbnormalInteract();
|
|
await fetchPatrolAbnormalInteract();
|
|
|
await fetchCropQuestionAlbumPic();
|
|
await fetchCropQuestionAlbumPic();
|
|
|
await fetchReportList();
|
|
await fetchReportList();
|
|
|
|
|
+ await fetchCropArchiveList();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
const goAddZone = (type) => {
|
|
const goAddZone = (type) => {
|