lxf 1 неделя назад
Родитель
Сommit
e215493ba0

BIN
src/assets/img/common/fn.png


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

@@ -83,13 +83,25 @@ 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);
+/** 接口 is_use:'1' 开放,'0' 未开放;会话缓存无该字段时按当前列表 crop_id 解析 */
+const isCropAllowed = (item) => {
+    if (item?.is_use != null && item.is_use !== "") {
+        return String(item.is_use) === "1";
+    }
+    const id = item?.id;
+    if (id == null) return false;
+    for (const tab of majorTabs.value) {
+        for (const group of tab.groups || []) {
+            const found = (group.items || []).find((i) => String(i.id) === String(id));
+            if (found) return String(found.is_use ?? "0") === "1";
+        }
+    }
+    return false;
+};
 
 const props = defineProps({
     multiple: { type: Boolean, default: false },
@@ -163,6 +175,7 @@ const mapCropGroups = (list) => {
                 id: crop.crop_id,
                 name: crop.crop_name,
                 code: crop.crop_code || "",
+                is_use: crop.is_use ?? "0",
                 isAdvantage: !!crop.is_advantage,
                 advantageRank: crop.advantage_rank,
                 selected: false,