Browse Source

fix: 刷新数据

lxf 1 day ago
parent
commit
7b40bb3923

+ 2 - 1
src/components/editClientPopup.vue

@@ -16,7 +16,7 @@
                         <el-input class="input" v-model="ruleForm.name" size="large" placeholder="请输入姓名" />
                     </el-form-item>
                     <el-form-item label="电话" prop="tel">
-                        <el-input class="input" v-model="ruleForm.tel" size="large" placeholder="请输入电话号码" />
+                        <el-input disabled class="input" v-model="ruleForm.tel" size="large" placeholder="请输入电话号码" />
                     </el-form-item>
                     <el-form-item label="地址" prop="address">
                         <el-input class="input" v-model="ruleForm.address" size="large" placeholder="请输入地址" />
@@ -149,6 +149,7 @@ const resetForm = () => {
 
 // 打开弹窗-类型
 function openClientPopup(type, data) {
+    console.log('data', data);
     userId.value = data ? data.id : null;
     if (type === "edit") {
         ruleForm.name = data.name;

+ 1 - 3
src/views/home/components/applyList.vue

@@ -193,9 +193,7 @@ function warningMessage(name, id) {
 watch(
     () => props.startReloadList,
     (newVal) => {
-        if (newVal) {
-            getUserList(); // 重新加载用户列表
-        }
+        getUserList(); // 重新加载用户列表
     }
 );
 

+ 1 - 3
src/views/home/components/clientList.vue

@@ -225,9 +225,7 @@ watch(
 watch(
     () => props.startReloadList,
     (newVal) => {
-        if (newVal) {
-            getUserList(); // 重新加载用户列表
-        }
+        getUserList(); // 重新加载用户列表
     }
 );
 

+ 142 - 0
src/views/home/homeMap.vue

@@ -1,5 +1,25 @@
 <template>
     <div>
+        <div class="search-wrap">
+            <el-autocomplete
+                v-model="searchWord"
+                :fetch-suggestions="querySearch"
+                placeholder="搜索用户昵称/手机号"
+                :prefix-icon="Search"
+                @select="handleSelect"
+                clearable
+                style="width: 100%"
+                size="large"
+            >
+                <template #default="{ item }">
+                    <div class="map-search-item">
+                        <el-avatar :size="26" :src="item.icon" />
+                        <div class="name">{{ item.userNickName || item.makeName }}</div>
+                        <div class="tel">{{ item.tel || item.makeTel }}</div>
+                    </div>
+                </template>
+            </el-autocomplete>
+        </div>
         <div id="map" ref="areaRef" class="area-map"></div>
         <album-carousel></album-carousel>
     </div>
@@ -23,6 +43,7 @@ import { onMounted, ref } from "vue";
 import { useStore } from "vuex";
 import { unByKey } from "ol/Observable";
 import { deepClone } from "@/common/commonFun";
+import { Search } from '@element-plus/icons-vue';
 
 const store = useStore();
 const areaRef = ref(null);
@@ -433,6 +454,82 @@ const resetCurrentTree = () => {
     }
 };
 
+// 搜索
+// 搜索相关代码
+const searchWord = ref('')
+const searchResults = ref([])
+
+
+// 搜索方法
+const querySearch = (queryString, cb) => {
+    if (!queryString || !mapPoint.value?.length) {
+        cb([])
+        return
+    }
+    const results = mapPoint.value.filter(item => {
+        const searchFields = [
+            item.tel,
+            item.userNickName,
+            item.makeTel,
+            item.makeName
+        ].filter(Boolean).map(f => f.toString().toLowerCase())
+        return searchFields.some(field => 
+            field.includes(queryString.toLowerCase())
+        )
+    })
+        console.log('results', results, mapPoint.value);
+    
+    // 格式化结果供el-autocomplete使用
+    const formattedResults = results.map(item => ({
+        ...item,
+        value: item.userNickName || item.makeName || '未命名点位'
+    }))
+    
+    cb(formattedResults)
+}
+
+// 选中搜索结果项
+const handleSelect = (item) => {
+    if (!item || !item.geom) return
+    
+    try {
+        // 定位到选中的点位
+        const coordinate = util.wktCastGeom(item.geom).getFirstCoordinate()
+        kmap.getView().animate({
+            center: coordinate,
+            zoom: 22,
+            duration: 500
+        })
+        
+        // 高亮显示选中的点位
+        // if (treeClusterLayer) {
+        //     treeClusterLayer.layer.getSource().getSource().getFeatures().forEach(feature => {
+        //         if (feature.get('sampleId') === item.sampleId) {
+        //             feature.set('highlight', true)
+        //             refreshClusterStyle()
+                    
+        //             // 3秒后取消高亮
+        //             setTimeout(() => {
+        //                 feature.set('highlight', false)
+        //                 refreshClusterStyle()
+        //             }, 3000)
+        //         }
+        //     })
+        // }
+
+        setTimeout(() => {
+            eventBus.emit("click:point", { 
+                farmId: currentFarmId, 
+                sampleId: item.sampleId, 
+                data: item
+            });
+        }, 1000)
+    } catch (e) {
+        console.error('定位失败:', e)
+    }
+}
+
+
 // 初始化区域地图
 const initAreaMap = (arr) => {
     regionLayer?.initData(arr);
@@ -457,4 +554,49 @@ const emit = defineEmits(["update:selectedTree"]);
     width: 100%;
     height: 100%;
 }
+// .search-wrap {
+//     position: absolute;
+//     top: 10px;
+//     right: 410px;
+//     z-index: 10;
+//     ::v-deep {
+//         .el-input__wrapper {
+//             background: rgba(255, 255, 255, 0.8);
+//             box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.88) inset;
+//         }
+//     }
+// }
+.search-wrap {
+    position: absolute;
+    top: 10px;
+    right: 410px;
+    z-index: 10;
+    width: 300px;
+    
+    ::v-deep {
+        .el-input__wrapper {
+            background: rgba(255, 255, 255, 0.8);
+            box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.88) inset;
+        }
+    }
+    
+}
+</style>
+
+<style lang="less">
+.map-search-item {
+    display: flex;
+    align-items: center;
+    padding: 5px 0;
+    
+    .name {
+        font-weight: bold;
+        padding: 0 8px;
+    }
+    
+    .tel {
+        color: #888;
+        font-size: 12px;
+    }
+}
 </style>

+ 9 - 4
src/views/home/index.vue

@@ -31,7 +31,7 @@
                             <el-tab-pane label="已分配" name="已分配">
                                 <apply-list
                                     :startReloadList="startReloadList"
-                                    @update:userList="setReload"
+                                    @update:userList="updateUser"
                                 ></apply-list>
                             </el-tab-pane>
                             <!-- <el-tab-pane label="确认地址" name="确认地址">
@@ -242,7 +242,7 @@ const saveDistributeEdit = () => {
     VE_API.manage_interface.saveTreeUser(params).then(({code}) => {
         if (code === 0) {
             ElMessage.success("分配成功");
-            startReloadList.value = true; // 触发重新加载列表
+            startReloadList.value = !startReloadList.value // 触发重新加载列表
             activeName.value = "已分配"
             handleCancel()
             return;
@@ -291,7 +291,12 @@ function backHome() {
 }
 
 function setReload() {
-    startReloadList.value = true
+    startReloadList.value = !startReloadList.value
+}
+
+function updateUser() {
+    activeName.value = "待分配"
+    setReload()
 }
 </script>
 
@@ -522,7 +527,7 @@ function setReload() {
             }
             .disabled {
                 opacity: 0.6;
-                pointer-events: none;
+                cursor: not-allowed;
             }
         }
         .select-text {