Explorar o código

feat:修改编辑农场和新增农场

wangsisi hai 1 semana
pai
achega
63e3fd0eb8

+ 3 - 3
src/components/weatherInfo.vue

@@ -198,9 +198,9 @@ const handleAddGarden = () => {
                         font-weight: 500;
                         color: #000000;
                         span {
-                            // max-width: fit-content;
-                            width: 100%;
-                            display: inline-block;
+                            width: fit-content;
+                            max-width: 100%;
+                            margin-right: 4px;
                         }
 
                         .default-text {

+ 10 - 20
src/views/old_mini/album_recognize/index.vue

@@ -19,12 +19,12 @@
                     <img class="card-bg" :src="base_img_url2 + imgKey + resize" />
                     <div class="card-content" v-if="!isRecognize && !noData">
                         <div class="title-ques">
-                            <div class="ques-text">病虫名称:{{resList?.name}}</div>
+                            <div class="ques-text">病虫名称:{{ resList?.name }}</div>
                         </div>
                         <div class="dialog-famous">管理方法:</div>
-                        <div class="dialog-answer" >
+                        <div class="dialog-answer">
                             {{ resList.cure }}
-                          <!-- <template v-if="resData?.phenologyName">
+                            <!-- <template v-if="resData?.phenologyName">
                             ,物候期为<span style="color: #ffd786;">{{resData?.phenologyName}}</span>
                           </template>
                           <template v-if="resData?.pestOrDiseaseName">
@@ -73,25 +73,22 @@ import { base_img_url2 } from "@/api/config.js";
 import wx from "weixin-js-sdk";
 import MqttClient from "@/mqtt/MqttClient";
 
-const MQTT_MQTTIP = "wss://ws.emqx.sysuimars.cn/mqtt";
-const MQTT_USERNAME = "admin";
-const MQTT_PASSWORD = "admin";
-
 let resize = '?x-oss-process=image/resize,w_300'
 const route = useRoute();
-const json = JSON.parse(route.query.json || "{}");
-// const json = JSON.parse(`{"imgKey":"birdseye-look-mini/766/1761388777261.png","imgId":769993591052308480}`)
+// const json = JSON.parse(route.query.json || "{}");
+const json = JSON.parse(`{"imgKey":["birdseye-look-mini/766/1761548221155.png","birdseye-look-mini/766/1761548221431.png"],"imgId":["770662355804622848","770662355804622849"],"farmId":766,"token":"bcc0e12d-bff6-4f1f-8edc-2ab80b19af41"}`)
 const imgKey = json.imgKey;
 const farmId = json.farmId;
 
 const isRecognize = ref(true);
-
 const recoginizeResult = ref({});
 const noData = ref(false);
 const resList = ref({});
 onMounted(() => {
+    console.log(json,'json')
+    const aaa = `{"result":["06"],"updateTime":"2025-10-27T15:03:44.859","taskId":"18","imageIds":[770662364482637824,770662364482637825],"status":1}`
+    console.log(JSON.parse(aaa),'JSON.parse(aaa)')
     const mqttClient = new MqttClient(['farm/pest_recognition/task/'+farmId], mqttListener);
-    // const mqttClient = new MqttClient(['phone/image/update/+'], mqttListener);
     mqttClient.connect();
 });
 
@@ -110,14 +107,7 @@ const mqttListener = (topic, message) => {
     }else{
         noData.value = true;
     }
-    // else if(resData.value?.growthAbnormalId){
-    //     VE_API.growth_anomaly_type.getById({id:resData.value?.growthAbnormalId}).then(({data})=>{
-    //       resData.value.suggest = data.suggest;
-    //     })
-    // }
     isRecognize.value = false;
-    // recoginizeResult.value.text1 = resData.data.text1
-    // recoginizeResult.value.text2 = resData.data.text2
   }
 }
 
@@ -257,7 +247,7 @@ const toRecognize = () => {
                         width: fit-content;
                         padding: 4px 10px;
                         border-radius: 20px;
-                        color: #FFD786;
+                        color: #ffd786;
                         background: rgba(255, 215, 134, 0.2);
                         margin-bottom: 6px;
                     }
@@ -314,7 +304,7 @@ const toRecognize = () => {
                     width: 20%;
                     min-width: 80px;
                     text-align: center;
-                    border: 1px solid #8E8E8E;
+                    border: 1px solid #8e8e8e;
                 }
             }
             .btn + .btn {

+ 7 - 20
src/views/old_mini/create_farm/index.vue

@@ -128,12 +128,7 @@
                                             @input="handleFarmNameInput"
                                         />
                                     </el-form-item>
-                                    <el-form-item label="默认农场" prop="default-farm" class="defaultFarm">
-                                        <radio-group class="radio-group" v-model="ruleForm.defaultFarm" direction="horizontal">
-                                            <radio class="radio-item" :name="true">是</radio>
-                                            <radio class="radio-item" :name="false">否</radio>
-                                        </radio-group>
-                                    </el-form-item>
+                                    <checkbox class="checkbox" icon-size="18px" shape="square" v-model="ruleForm.defaultFarm">是否勾选为默认农场</checkbox>
                                 </el-form>
                             </div>
                             <div class="create-btn">
@@ -159,7 +154,7 @@ import { onMounted, ref, reactive, watch, onActivated } from "vue";
 import { useStore } from "vuex";
 import { convertPointToArray } from "@/utils/index";
 import { ElMessage } from "element-plus";
-import { RadioGroup, Radio } from "vant";
+import { Checkbox } from "vant";
 import { transformFromGCJToWGS, transformFromWGSToGCJ } from "@/utils/WSCoordinate.js";
 
 const route = useRoute();
@@ -500,8 +495,8 @@ const submitForm = (formEl) => {
                     // 根据来源页面决定跳转目标
                     const fromPage = route.query.from;
                     if (fromPage === 'monitor') {
-                        // 如果是从monitor页面来的,跳转回monitor页面并刷新农场列表和基本信息弹窗
-                        router.replace(`/${fromPage}?refreshFarmInfo=true`);
+                        // 如果是从monitor页面来的
+                        router.replace(`/${fromPage}`);
                     } else {
                         // 默认跳转到首页
                         router.replace("/home?reload=true&showSuccess=true");
@@ -818,10 +813,9 @@ function handleMianjiInput(value) {
         width: 100%;
         height: calc(100% - 320px);
     }
-    .radio-group {
-        .radio-item {
-            margin-right: 30px;
-        }
+    .checkbox{
+        padding: 0 12px 6px;
+        font-size: 15px;
     }
     .farm-content {
         position: absolute;
@@ -1005,17 +999,10 @@ function handleMianjiInput(value) {
                             height: 1px;
                             background: rgba(0, 0, 0, 0.08);
                         }
-                        &.default-farm {
-                            margin-bottom: 0;
-                            &::after {
-                                background: none;
-                            }
-                        }
                     }
                     .el-input__wrapper {
                         box-shadow: none;
                         padding: 1px 6px;
-                        // border-bottom: 1px solid rgba(0, 0, 0, 0.08);
                     }
                 }
                 .area-box {

+ 10 - 17
src/views/old_mini/home/components/farmInfoPopup.vue

@@ -21,15 +21,8 @@
                     </field>
                     <field v-model="farmInfo.fzr" readonly label="联系人" />
                     <field v-model="farmInfo.tel" readonly label="联系电话" />
-                    <field readonly label="默认农场">
-                        <template #input>
-                            <radio-group class="radio-group" v-model="farmInfo.defaultOption" direction="horizontal">
-                                <radio class="radio-item" :name="true">是</radio>
-                                <radio class="radio-item" :name="false">否</radio>
-                            </radio-group>
-                        </template>
-                    </field>
                     <field class="address-field" v-model="farmInfo.address" readonly label="农场位置" />
+                    <checkbox class="checkbox" icon-size="16px" shape="square" v-model="farmInfo.defaultOption">是否勾选为默认农场</checkbox>
                 </cell-group>
             </div>
             <div class="popup-footer">
@@ -41,7 +34,7 @@
 </template>
 
 <script setup>
-import { Popup, Field, CellGroup, RadioGroup, Radio } from "vant";
+import { Popup, Field, CellGroup, Checkbox } from "vant";
 import { ref, nextTick } from "vue";
 import { useRouter } from "vue-router";
 import IndexMap from "../map/index.js";
@@ -108,6 +101,10 @@ const handleEditMap = () => {
 };
 
 const handleEdit = () => {
+    setTimeout(() => {
+        show.value = false;
+    }, 50);
+
     // 在跳转前,将当前农场的地块数据存储到store中
     if (farmInfo.value.geomWkt) {
         const polygonData = {
@@ -190,16 +187,12 @@ defineExpose({ handleShow });
                     transform: scaleY(0.5);
                 }
             }
-            .radio-group {
-                display: flex;
-                align-items: center;
-                pointer-events: none;
-                .radio-item {
-                    margin-right: 30px;
-                }
-            }
         }
     }
+    .checkbox {
+        pointer-events: none;
+        padding: 12px 14px;
+    }
     .popup-footer {
         display: flex;
         gap: 13px;

+ 0 - 14
src/views/old_mini/monitor/index.vue

@@ -251,20 +251,6 @@ const handleBroadcast = () => {
 // 组件激活时检查是否需要刷新农场列表
 onActivated(() => {
     weatherInfoRef.value.getFarmList();
-    
-    // 检查是否从编辑农场页面返回,需要刷新基本信息弹窗
-    if (route.query.refreshFarmInfo === 'true') {
-        // 清除URL参数,避免刷新页面时再次触发
-        router.replace({ 
-            path: '/monitor', 
-            query: {} 
-        });
-        
-        // 刷新农场信息弹窗数据
-        if (farmInfoRef.value) {
-            farmInfoRef.value.handleShow();
-        }
-    }
 });
 
 // 组件卸载时停止语音播放