lxf 3 недель назад
Родитель
Сommit
5a08eacb26

+ 44 - 33
src/components/allGarden.vue

@@ -141,40 +141,33 @@ const farmList = ref([]);
 const searchFarm = ref("");
 const regionVal = ref("");
 const typeVal = ref("");
-
-const regionOptions = computed(() => {
-    const set = new Set();
-    farmList.value.forEach((farm) => {
+/** 筛选项从历次接口结果累计,避免筛选后下拉变空 */
+const regionOptionSet = ref(new Set());
+const typeOptionSet = ref(new Set());
+let searchTimer = null;
+
+const regionOptions = computed(() =>
+    Array.from(regionOptionSet.value).map((value) => ({ label: value, value }))
+);
+
+const typeOptions = computed(() =>
+    Array.from(typeOptionSet.value).map((value) => ({ label: value, value }))
+);
+
+/** 列表由接口按 farm_name / region / crop 筛选 */
+const filteredFarmList = computed(() => farmList.value);
+
+function collectFilterOptions(list) {
+    const nextRegions = new Set(regionOptionSet.value);
+    const nextTypes = new Set(typeOptionSet.value);
+    (list || []).forEach((farm) => {
         const region = farm.city || farm.farm_city || "";
-        if (region) set.add(region);
-    });
-    return Array.from(set).map((value) => ({ label: value, value }));
-});
-
-const typeOptions = computed(() => {
-    const set = new Set();
-    farmList.value.forEach((farm) => {
-        if (farm.categoryLabel) set.add(farm.categoryLabel);
-    });
-    return Array.from(set).map((value) => ({ label: value, value }));
-});
-
-const filteredFarmList = computed(() => {
-    const keyword = searchFarm.value.trim().toLowerCase();
-    return farmList.value.filter((farm) => {
-        if (keyword && !(farm.name || "").toLowerCase().includes(keyword)) {
-            return false;
-        }
-        if (regionVal.value) {
-            const region = farm.city || farm.farm_city || "";
-            if (region !== regionVal.value) return false;
-        }
-        if (typeVal.value && farm.categoryLabel !== typeVal.value) {
-            return false;
-        }
-        return true;
+        if (region) nextRegions.add(region);
+        if (farm.categoryLabel) nextTypes.add(farm.categoryLabel);
     });
-});
+    regionOptionSet.value = nextRegions;
+    typeOptionSet.value = nextTypes;
+}
 
 function resolveFarmPointWkt(farm) {
     if (farm.geom_wkt && /^POINT\s*\(/i.test(String(farm.geom_wkt).trim())) {
@@ -259,11 +252,18 @@ function getFarmList() {
         farmList.value = [];
         return;
     }
+    const params = { id };
+    const farmName = searchFarm.value.trim();
+    if (farmName) params.farm_name = farmName;
+    if (regionVal.value) params.region = regionVal.value;
+    if (typeVal.value) params.crop = typeVal.value;
+
     VE_API.questionnaire
-        .getFarms({ id })
+        .getFarms(params)
         .then((res) => {
             const list = Array.isArray(res?.data) ? res.data : [];
             farmList.value = normalizeFarmList(list);
+            collectFilterOptions(farmList.value);
             nextTick(() => {
                 ensureMap();
             });
@@ -301,6 +301,17 @@ watch(filteredFarmList, () => {
     }
 });
 
+watch([regionVal, typeVal], () => {
+    getFarmList();
+});
+
+watch(searchFarm, () => {
+    if (searchTimer) clearTimeout(searchTimer);
+    searchTimer = setTimeout(() => {
+        getFarmList();
+    }, 300);
+});
+
 onMounted(() => {
     getFarmList();
     nextTick(() => {

+ 6 - 4
src/components/popup/restorePlantingPopup.vue

@@ -90,16 +90,18 @@
             </div>
 
             <div class="restore-planting-popup__actions">
-                <div
+                <el-button
+                    type="primary"
                     class="restore-planting-popup__btn restore-planting-popup__btn--primary"
                     :class="{ disabled: submitting }"
                     @click="handleConfirm"
+                    :loading="submitting"
                 >
-                    <span v-if="submitting" class="restore-planting-popup__btn-loading">
+                    <!-- <span v-if="!submitting" class="restore-planting-popup__btn-loading">
                         <el-icon><Loading /></el-icon>
-                    </span>
+                    </span> -->
                     {{ questionType === "time" ? t("agriFile.confirmNow") : t("agriFile.submitInfo") }}
-                </div>
+                </el-button>
             </div>
         </div>
     </popup>

+ 11 - 0
src/views/old_mini/agri_file/pages/diagnosisReport.vue

@@ -202,6 +202,14 @@ function getSelectedFarm() {
     }
 }
 
+/** 与 diagnosisReportPopup 同源:标记该农场/分区弹窗已读 */
+const DIAGNOSIS_POPUP_SHOWN_PREFIX = "DIAGNOSIS_REPORT_POPUP_SHOWN_";
+function markDiagnosisPopupShown(farmId, zoneId) {
+    if (farmId == null || farmId === "") return;
+    const key = `${DIAGNOSIS_POPUP_SHOWN_PREFIX}${farmId}_${zoneId ?? ""}`;
+    localStorage.setItem(key, "1");
+}
+
 /** 解析 module1_basic:兼容 `**标签**:` 与纯文本 `标签:`(内容可跨行) */
 function parseBasicSections(markdown = "") {
     const text = String(markdown).replace(/\r\n/g, "\n").trim();
@@ -394,6 +402,8 @@ async function pollDiagnosisReport(farmId, zoneId) {
         const res = Array.isArray(raw) ? raw[0] : raw;
         const report = res?.data?.report;
         if (res?.code === 200 && report) {
+            // 进入报告页并拿到数据:标记该农场弹窗已读,避免再弹
+            markDiagnosisPopupShown(farmId, zoneId);
             stopReportPolling();
             reportGenerating.value = false;
             applyReportData(report, getSelectedFarm());
@@ -425,6 +435,7 @@ async function fetchDiagnosisReport() {
         const res = Array.isArray(raw) ? raw[0] : raw;
         const report = res?.data?.report;
         if (res?.code === 200 && report) {
+            markDiagnosisPopupShown(farmId, zoneId);
             applyReportData(report, farm);
             return;
         }