Przeglądaj źródła

feat:添加品种分类和果园接口对接

wangsisi 1 tydzień temu
rodzic
commit
87c19a0b24

+ 4 - 0
src/api/modules/farm.js

@@ -21,6 +21,10 @@ module.exports = {
         url: config.base_dev_url + "v2/farm/userFarmSelectOption",
         type: "get",
     },
+    listByUserId: {
+        url: config.base_dev_url + "farm_subject/listByUserId",
+        type: "get",
+    },
     fruitsTypeItemList: {
         url: config.base_dev_url + "mini_fruits_type_item/list/{parentId}",
         type: "get",

+ 6 - 6
src/components/weatherInfo.vue

@@ -97,7 +97,7 @@ const handleCommand = ({id, name}) => {
     localStorage.setItem('selectedFarmId', id);
     localStorage.setItem('selectedFarmName', name);
     localStorage.setItem('selectedFarmPoint', selectedFarm.point);
-    getLocationName();
+    // getLocationName();
     getWeatherData();
     emit('changeGarden',{id, name});
 };
@@ -125,7 +125,7 @@ async function setFarmByGardenId(gardenIdValue) {
     
     // 先刷新农场列表,确保数据是最新的
     return new Promise((resolve) => {
-        VE_API.farm.userFarmSelectOption({agriculturalQuery: false}).then(({data}) => {
+        VE_API.farm.listByUserId().then(({data}) => {
             // const fullData = data.filter(item => item.userType === 2);
             const fullData = data;
             farmList.value = fullData || [];
@@ -140,7 +140,7 @@ async function setFarmByGardenId(gardenIdValue) {
                     localStorage.setItem('selectedFarmName', farmName.value);
                     localStorage.setItem('selectedFarmPoint', targetFarm.point);
 
-                    getLocationName();
+                    // getLocationName();
                     getWeatherData();
                     emit('changeGarden', { id: farmId.value, name: farmName.value });
                     resolve(true);
@@ -197,14 +197,14 @@ function selectFarmFromList(data) {
         // 如果没有保存的选择,按优先级选择
         selectDefaultFarm(data);
     }
-    getLocationName();
+    // getLocationName();
     getWeatherData();
     emit('changeGarden',{id: farmId.value, name: farmName.value});
 }
 
 // 获取农场列表(不处理传入的gardenId)
 function getFarmListWithoutGardenId() {
-    VE_API.farm.userFarmSelectOption({agriculturalQuery: false}).then(({data}) => {
+    VE_API.farm.listByUserId().then(({data}) => {
         // const fullData = data.filter(item => item.userType === 2);
         const fullData = data;
         farmList.value = fullData || [];
@@ -245,7 +245,7 @@ function selectDefaultFarm(data) {
     localStorage.setItem('selectedFarmId', farmId.value);
     localStorage.setItem('selectedFarmName', farmName.value);
     localStorage.setItem('selectedFarmPoint', data[0].point);
-    getLocationName();
+    // getLocationName();
     getWeatherData();
 }
 

+ 5 - 3
src/views/old_mini/home/index.vue

@@ -186,9 +186,11 @@ const changeGarden = ({ id }) => {
 
 const expertInfo = ref({});
 const getExpertByFarmId = () => {
-    VE_API.home.getExpertByFarmId({ farmId: gardenId.value }).then(({ data }) => {
-        expertInfo.value = data || {};
-        sessionStorage.setItem("expertId", data.appUserId);
+    VE_API.home.getExpertByFarmId({ farmId: gardenId.value }).then(({ data, code }) => {
+       if(code === 0) {
+            expertInfo.value = data || {};
+            sessionStorage.setItem("expertId", data.appUserId);
+        }
     });
 };
 

+ 41 - 1
src/views/old_mini/monitor/index.vue

@@ -12,6 +12,18 @@
                 <div class="line-title">作物档案</div>
                 <!-- <el-date-picker style="width: 110px" v-model="date" type="year" placeholder="全部日期" /> -->
             </div>
+            <!-- 品种选择 -->
+            <div class="variety-tabs">
+                <div
+                    v-for="v in varietyTabs"
+                    :key="v.key"
+                    class="variety-tab"
+                    :class="{ 'variety-tab--active': activeVariety === v.key }"
+                    @click="activeVariety = v.key"
+                >
+                    {{ v.label }}
+                </div>
+            </div>
             <div class="archives-time-line-content">
                 <div class="report-box" v-if="hasReport">
                     <div class="box-content">
@@ -53,6 +65,15 @@ import { ElMessage, ElMessageBox } from "element-plus";
 import ArchivesFarmTimeLine from "@/components/pageComponents/ArchivesFarmTimeLine.vue";
 import agriExecutePopup from "@/components/popup/agriExecutePopup.vue";
 
+// 品种选择(作物档案内)
+const varietyTabs = [
+    { key: "feizixiao", label: "妃子笑" },
+    { key: "guiwei", label: "桂味" },
+    { key: "nuomici", label: "糯米糍" },
+    { key: "xiantaofang", label: "仙桃芳" },
+];
+const activeVariety = ref("feizixiao");
+
 const handleJump = () =>{
     router.push('/create_farm?type=farmer&expertMiniUserId=81881&isReload=true')
 }
@@ -434,9 +455,28 @@ const getReport = () => {
             }
         }
 
+        .variety-tabs {
+            display: flex;
+            align-items: center;
+            gap: 8px;
+            margin: 10px 0;
+
+            .variety-tab {
+                padding: 4px 12px;
+                border-radius: 2px;
+                color: #767676;
+                background: #fff;
+            }
+
+            .variety-tab--active {
+                background: #2199F8;
+                color: #ffffff;
+            }
+        }
+
         .archives-time-line-content {
             margin-top: 10px;
-            height: calc(100% - 32px);
+            height: calc(100% - 70px);
             background: #fff;
             border-radius: 8px;
             padding: 10px;