|
@@ -80,18 +80,21 @@
|
|
|
@switchGrowing="handleSwitchGrowing"
|
|
@switchGrowing="handleSwitchGrowing"
|
|
|
/>
|
|
/>
|
|
|
<editPlantPointPopup ref="editPlantPointPopupRef" @confirm="handlePlantPointConfirm" />
|
|
<editPlantPointPopup ref="editPlantPointPopupRef" @confirm="handlePlantPointConfirm" />
|
|
|
|
|
+ <complete-farm-info-popup v-model:show="showCompleteFarmPopup" @confirm="goCompleteFarmInfo" />
|
|
|
<restore-planting-popup />
|
|
<restore-planting-popup />
|
|
|
</div>
|
|
</div>
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<script setup>
|
|
<script setup>
|
|
|
-import { computed, onActivated, onMounted, ref } from "vue";
|
|
|
|
|
|
|
+import { computed, onActivated, ref } from "vue";
|
|
|
import { useRouter } from "vue-router";
|
|
import { useRouter } from "vue-router";
|
|
|
|
|
+import { useStore } from "vuex";
|
|
|
import { ElMessage } from "element-plus";
|
|
import { ElMessage } from "element-plus";
|
|
|
import { Plus, Edit } from "@element-plus/icons-vue";
|
|
import { Plus, Edit } from "@element-plus/icons-vue";
|
|
|
import adjustPhenologyPopup from "../components/adjustPhenologyPopup.vue";
|
|
import adjustPhenologyPopup from "../components/adjustPhenologyPopup.vue";
|
|
|
import restingDatePopup from "../components/restingDatePopup.vue";
|
|
import restingDatePopup from "../components/restingDatePopup.vue";
|
|
|
import editPlantPointPopup from "../components/editPlantPointPopup.vue";
|
|
import editPlantPointPopup from "../components/editPlantPointPopup.vue";
|
|
|
|
|
+import completeFarmInfoPopup from "@/components/popup/completeFarmInfoPopup.vue";
|
|
|
import tab1Icon from "@/assets/img/report/tab-1.png";
|
|
import tab1Icon from "@/assets/img/report/tab-1.png";
|
|
|
import tab2Icon from "@/assets/img/report/tab-2.png";
|
|
import tab2Icon from "@/assets/img/report/tab-2.png";
|
|
|
import tab3Icon from "@/assets/img/report/tab-3.png";
|
|
import tab3Icon from "@/assets/img/report/tab-3.png";
|
|
@@ -103,6 +106,7 @@ import restorePlantingPopup from "@/components/popup/restorePlantingPopup.vue";
|
|
|
// Props / Emits — 无
|
|
// Props / Emits — 无
|
|
|
// ---------------------------------------------------------------------------
|
|
// ---------------------------------------------------------------------------
|
|
|
const router = useRouter();
|
|
const router = useRouter();
|
|
|
|
|
+const store = useStore();
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// ---------------------------------------------------------------------------
|
|
|
// 常量
|
|
// 常量
|
|
@@ -148,6 +152,7 @@ const activeReportTab = ref("weather");
|
|
|
const adjustPhenologyPopupRef = ref(null);
|
|
const adjustPhenologyPopupRef = ref(null);
|
|
|
const restingDatePopupRef = ref(null);
|
|
const restingDatePopupRef = ref(null);
|
|
|
const editPlantPointPopupRef = 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() {
|
|
function getSelectedFarm() {
|
|
|
try {
|
|
try {
|
|
|
return JSON.parse(localStorage.getItem("selectedFarmData") || "{}");
|
|
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() {
|
|
async function fetchDiagnosisReport() {
|
|
|
const farm = getSelectedFarm();
|
|
const farm = getSelectedFarm();
|
|
|
const farmId = farm.farm_id ?? farm.id;
|
|
const farmId = farm.farm_id ?? farm.id;
|
|
@@ -347,7 +373,7 @@ async function fetchDiagnosisReport() {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
resetReportView(farm);
|
|
resetReportView(farm);
|
|
|
- ElMessage.warning(res?.msg || res?.message || "暂无诊断报告");
|
|
|
|
|
|
|
+ ElMessage.warning(res?.msg || res?.message || "报告正在生成中...");
|
|
|
} catch (error) {
|
|
} catch (error) {
|
|
|
console.error("fetchDiagnosisReport failed", error);
|
|
console.error("fetchDiagnosisReport failed", error);
|
|
|
resetReportView(farm);
|
|
resetReportView(farm);
|
|
@@ -392,9 +418,15 @@ const handlePlantPointConfirm = (payload) => {
|
|
|
console.log("plant point confirm:", 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>
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
<style lang="scss" scoped>
|