4
0

2 Revīzijas 9617347dde ... 34c04e125a

Autors SHA1 Ziņojums Datums
  wangsisi 34c04e125a Merge branch 'agriculture' of http://www.sysuimars.cn:3000/feiniao/feiniao-farm-h5 into agriculture 3 nedēļas atpakaļ
  wangsisi 4dc0360238 fix:修改bug 3 nedēļas atpakaļ

+ 27 - 4
src/components/popup/diagnosisReportPopup.vue

@@ -63,6 +63,30 @@ const markPopupShown = (farmId, zoneId) => {
     localStorage.setItem(getShownCacheKey(farmId, zoneId), "1");
 };
 
+/** 当前选中农场;接口必传 farm_id / zone_id */
+const readSelectedFarm = () => {
+    try {
+        return JSON.parse(localStorage.getItem("selectedFarmData") || "null") || {};
+    } catch {
+        return {};
+    }
+};
+
+const readFarmId = () => {
+    const farm = readSelectedFarm();
+    const id = farm.farm_id ?? farm.id;
+    if (id != null && id !== "") return id;
+    return localStorage.getItem("selectedFarmId") || "";
+};
+
+const readZoneId = () => {
+    const farm = readSelectedFarm();
+    const id = farm.zone_id ?? farm.zoneId;
+    return id != null && id !== "" ? id : "";
+};
+
+let checking = false;
+
 /** exists=2 且本地未展示过时弹窗(不依赖物候确认) */
 const checkShouldShow = async () => {
     const farmId = getSelectedFarmId();
@@ -71,6 +95,7 @@ const checkShouldShow = async () => {
         visible.value = false;
         return;
     }
+    checking = true;
     try {
         const res = await VE_API.questionnaire.checkReportGenerated({
             farm_id: farmId,
@@ -81,6 +106,8 @@ const checkShouldShow = async () => {
         if (shouldShow) markPopupShown(farmId, zoneId);
     } catch {
         visible.value = false;
+    } finally {
+        checking = false;
     }
 };
 
@@ -97,10 +124,6 @@ watch(visible, (val, oldVal) => {
     if (oldVal && !val) markPopupShown(getSelectedFarmId(), getSelectedZoneId());
 });
 
-onMounted(() => {
-    checkShouldShow();
-});
-
 onActivated(() => {
     checkShouldShow();
 });

+ 1 - 1
src/i18n/messages.js

@@ -355,7 +355,7 @@ export default {
             before: "前",
             after: "后",
             fromFarm: "来自某某农场农场",
-            noData: "近期暂无农事",
+            noData: "近期暂无待做农事",
             all: "全部",
             highRisk: "高风险",
             executeAreaLabel: "执行区域:",

+ 38 - 6
src/views/old_mini/agri_file/pages/diagnosisReport.vue

@@ -80,18 +80,21 @@
             @switchGrowing="handleSwitchGrowing"
         />
         <editPlantPointPopup ref="editPlantPointPopupRef" @confirm="handlePlantPointConfirm" />
+        <complete-farm-info-popup v-model:show="showCompleteFarmPopup" @confirm="goCompleteFarmInfo" />
         <restore-planting-popup />
     </div>
 </template>
 
 <script setup>
-import { computed, onActivated, onMounted, ref } from "vue";
+import { computed, onActivated, ref } from "vue";
 import { useRouter } from "vue-router";
+import { useStore } from "vuex";
 import { ElMessage } from "element-plus";
 import { Plus, Edit } from "@element-plus/icons-vue";
 import adjustPhenologyPopup from "../components/adjustPhenologyPopup.vue";
 import restingDatePopup from "../components/restingDatePopup.vue";
 import editPlantPointPopup from "../components/editPlantPointPopup.vue";
+import completeFarmInfoPopup from "@/components/popup/completeFarmInfoPopup.vue";
 import tab1Icon from "@/assets/img/report/tab-1.png";
 import tab2Icon from "@/assets/img/report/tab-2.png";
 import tab3Icon from "@/assets/img/report/tab-3.png";
@@ -103,6 +106,7 @@ import restorePlantingPopup from "@/components/popup/restorePlantingPopup.vue";
 // Props / Emits — 无
 // ---------------------------------------------------------------------------
 const router = useRouter();
+const store = useStore();
 
 // ---------------------------------------------------------------------------
 // 常量
@@ -148,6 +152,7 @@ const activeReportTab = ref("weather");
 const adjustPhenologyPopupRef = ref(null);
 const restingDatePopupRef = ref(null);
 const editPlantPointPopupRef = ref(null);
+const showCompleteFarmPopup = ref(false); // 无农场时展示「完善农场信息」
 
 // ---------------------------------------------------------------------------
 // 计算属性
@@ -165,6 +170,10 @@ const activeReportHtml = computed(() => {
 // ---------------------------------------------------------------------------
 // 工具函数
 // ---------------------------------------------------------------------------
+function getMiniUserId() {
+    return store.state.home.miniUserId || localStorage.getItem("MINI_USER_ID");
+}
+
 function getSelectedFarm() {
     try {
         return JSON.parse(localStorage.getItem("selectedFarmData") || "{}");
@@ -322,8 +331,25 @@ function resetReportView(farm = {}) {
 }
 
 // ---------------------------------------------------------------------------
-// 业务逻辑:加载报告
+// 业务逻辑:无农场弹窗 / 加载报告
 // ---------------------------------------------------------------------------
+/** 无果园信息时展示「完善农场信息」弹窗 */
+async function checkCompleteFarmPopup() {
+    const id = getMiniUserId();
+    if (!id) {
+        showCompleteFarmPopup.value = false;
+        return;
+    }
+    try {
+        const res = await VE_API.questionnaire.getFarms({ id });
+        const list = Array.isArray(res?.data) ? res.data : [];
+        showCompleteFarmPopup.value = list.length === 0;
+    } catch (e) {
+        console.warn("[diagnosisReport] getFarms failed", e);
+        showCompleteFarmPopup.value = false;
+    }
+}
+
 async function fetchDiagnosisReport() {
     const farm = getSelectedFarm();
     const farmId = farm.farm_id ?? farm.id;
@@ -347,7 +373,7 @@ async function fetchDiagnosisReport() {
             return;
         }
         resetReportView(farm);
-        ElMessage.warning(res?.msg || res?.message || "暂无诊断报告");
+        ElMessage.warning(res?.msg || res?.message || "报告正在生成中...");
     } catch (error) {
         console.error("fetchDiagnosisReport failed", error);
         resetReportView(farm);
@@ -392,9 +418,15 @@ const handlePlantPointConfirm = (payload) => {
     console.log("plant point confirm:", payload);
 };
 
-// onMounted(fetchDiagnosisReport);
-// tabbar 切换时组件被 keep-alive 缓存,需在激活时重新拉报告
-onActivated(fetchDiagnosisReport);
+const goCompleteFarmInfo = () => {
+    router.push("/entry_information");
+};
+
+// tabbar 切换时组件被 keep-alive 缓存,需在激活时重新拉报告 / 校验农场
+onActivated(() => {
+    checkCompleteFarmPopup();
+    fetchDiagnosisReport();
+});
 </script>
 
 <style lang="scss" scoped>

+ 8 - 1
src/views/old_mini/entry_information/components/baInformation.vue

@@ -35,6 +35,8 @@
                             maxlength="11"
                             clearable
                             type="tel"
+                            inputmode="numeric"
+                            @input="onPhoneInput"
                         />
                     </el-form-item>
                     <el-form-item label="常驻点位" prop="location" class="location-form-item">
@@ -111,6 +113,11 @@ function readJson(key) {
     }
 }
 
+/** 手机号仅保留数字,最多 11 位(type=number 时 maxlength 不生效) */
+function onPhoneInput(val) {
+    form.phone = String(val ?? "").replace(/\D/g, "").slice(0, 11);
+}
+
 function saveFormDraft() {
     sessionStorage.setItem(
         FORM_KEY,
@@ -122,7 +129,7 @@ function restoreFormDraft() {
     const draft = readJson(FORM_KEY);
     if (!draft) return;
     if (draft.name != null) form.name = draft.name;
-    if (draft.phone != null) form.phone = draft.phone;
+    if (draft.phone != null) form.phone = String(draft.phone).replace(/\D/g, "").slice(0, 11);
 }
 
 function utilWktToCoordinate(point) {

+ 1 - 0
src/views/old_mini/entry_information/components/selectEquipment.vue

@@ -75,6 +75,7 @@
             :text="isService ? '您的信息已提交成功' : '您的信息已上传'"
             :text2="isService ? '' : '请等待诊断报告生成'"
             buttonText="完成"
+            :close-on-click-overlay="false"
             @confirm="handleComplete"
         />