Procházet zdrojové kódy

feat:添加品种提示和修改报告封面字段

wangsisi před 4 hodinami
rodič
revize
92d8879a87

+ 12 - 2
src/views/old_mini/agri_file/components/reportPanel.vue

@@ -21,12 +21,13 @@
 import { onActivated, onMounted, ref } from "vue";
 import { useI18n } from "@/i18n";
 import { useRouter } from "vue-router";
+import { base_img_url2 } from "@/api/config";
 
 const router = useRouter();
 const { t } = useI18n();
 
 // ---------- 常量 ----------
-const reportCover = require("@/assets/img/common/sd-1.jpg");
+const defaultCover = require("@/assets/img/common/sd-1.jpg");
 
 // ---------- 页面状态 ----------
 const reportList = ref([]);
@@ -40,13 +41,22 @@ const getSelectedFarm = () => {
     }
 };
 
+/** cover_url 可能是文件名或完整 URL */
+const resolveCoverUrl = (path) => {
+    if (!path) return defaultCover;
+    const text = String(path).trim();
+    if (!text) return defaultCover;
+    if (/^https?:\/\//i.test(text)) return text;
+    return base_img_url2 + text.replace(/^\//, "");
+};
+
 const mapReportItem = (item, index) => ({
     id: item.id ?? `${item.time || ""}-${index}`,
     title: item.title || "",
     type: item.type || "",
     desc: item.content || "",
     date: item.time || "",
-    cover: reportCover,
+    cover: resolveCoverUrl(item.cover_url),
 });
 
 const handleReportClick = (item) => {

+ 14 - 3
src/views/old_mini/entry_information/components/selectCategory.vue

@@ -80,10 +80,14 @@ const FIRST_CROP_KEY_MAP = {
     大田: "field",
 };
 const TAB_ORDER = ["果树", "大田"];
+/** 当前仅开放荔枝、水稻,其余点击提示暂未开放 */
+const ALLOWED_CROP_NAMES = new Set(["荔枝", "水稻"]);
 const DEFAULT_COUNTY_CODE = "440113";
 const MAP_KEY = "CZLBZ-LJICQ-R4A5J-BN62X-YXCRJ-GNBUT";
 const DEFAULT_POINT = "POINT(113.6142086995688 23.585836479509055)";
 
+const isCropAllowed = (item) => ALLOWED_CROP_NAMES.has(item?.name);
+
 const props = defineProps({
     multiple: { type: Boolean, default: false },
 });
@@ -212,7 +216,9 @@ const getCachedSelectedItems = () => {
         if (!raw) return [];
         const list = JSON.parse(raw);
         if (!Array.isArray(list)) return [];
-        return props.multiple ? list : list.slice(0, 1);
+        // 历史缓存可能含未开放品类,进页时过滤掉
+        const allowed = list.filter((item) => isCropAllowed(item));
+        return props.multiple ? allowed : allowed.slice(0, 1);
     } catch {
         return [];
     }
@@ -352,6 +358,10 @@ const handleSearch = () => {
 };
 
 const handleSelect = (item) => {
+    if (!isCropAllowed(item)) {
+        ElMessage.warning("该品种暂未开放");
+        return;
+    }
     if (props.multiple) {
         item.selected = !item.selected;
         persistSelection();
@@ -364,9 +374,10 @@ const handleSelect = (item) => {
 };
 
 const handleNext = () => {
-    const list = props.multiple
+    const list = (props.multiple
         ? sortFieldFirst(selectedItems.value)
-        : selectedItems.value.slice(0, 1);
+        : selectedItems.value.slice(0, 1)
+    ).filter((item) => isCropAllowed(item));
     if (!list.length) {
         ElMessage.warning(props.multiple ? "请选择种植品类" : "请选择一个种植品类");
         return;