diff --git a/.env.development b/.env.development index d12920d..3c0276d 100644 --- a/.env.development +++ b/.env.development @@ -3,7 +3,7 @@ ENV = 'development' # 接口地址 # 许镇-本地服地址 -VUE_APP_BASE_API = 'http://192.168.99.72:14000' +VUE_APP_BASE_API = 'http://192.168.99.63:14000' # VUE_APP_BASE_API = 'http://192.168.99.86:12010' #VUE_APP_BASE_API = 'http://27.19.205.234:17070' diff --git a/src/views/deviceManage/map3d/map.vue b/src/views/deviceManage/map3d/map.vue index 8dcf0f5..e70b308 100644 --- a/src/views/deviceManage/map3d/map.vue +++ b/src/views/deviceManage/map3d/map.vue @@ -175,6 +175,9 @@ export default { console.log('levelChanged:', event) console.log('当前楼层:', event.level) console.log('楼层name2', window.vueInstance.map.getFloor(event.level).name) + this.level = event.level + this.levelName = window.vueInstance.map.getFloor(event.level).name + window.vueInstance.$emit('refreshLevel', this.level, this.levelName) }) } catch (error) { console.error('初始化地图失败:', error) diff --git a/src/views/deviceManage/shelfManage/shelf3dPosition.vue b/src/views/deviceManage/shelfManage/shelf3dPosition.vue index 3daaa48..145c550 100644 --- a/src/views/deviceManage/shelfManage/shelf3dPosition.vue +++ b/src/views/deviceManage/shelfManage/shelf3dPosition.vue @@ -121,6 +121,7 @@ + @@ -282,7 +283,8 @@ export default { ], areaDetails: [ { id: 1, code: '03', name: '区域1' } - ] + ], + isMapSwitching: false // 地图楼层切换中,锁:禁止重复加载地图 } }, computed: { @@ -450,36 +452,76 @@ export default { return rootNode }, + // handleTreeNodeClick(nodeData) { + // this.form.layerVal = null + // this.form.shelfVal = null // 清空架位选择 + // this.rackOptions = [] // 清空架位列表 + // this.currentTreeNode = nodeData.raw + // console.log('handleTreeNodeClick', nodeData) + // const currentNode = this.$refs.treeRef.getNode(nodeData) + // console.log('currentNode', currentNode) + // if (currentNode.level === 1) { + // return + // } + // const parentNode = currentNode.parent + // const parentLabel = parentNode && parentNode.data && parentNode.data.label + // ? parentNode.data.label + // : '' + + // this.selectedValue = parentLabel + // ? `${parentLabel} - ${nodeData.label}` + // : nodeData.label + // this.$refs.selectRef.blur() + // this.getInitBookShelfList(currentNode.data) + + // if (nodeData.raw.mapType === 1) { + // this.is3DMap = false + // } else { + // this.is3DMap = true + // this.getMapDetails(nodeData.raw.mapId) + // } + // }, handleTreeNodeClick(nodeData) { - this.form.layerVal = null - this.form.shelfVal = null // 清空架位选择 - this.rackOptions = [] // 清空架位列表 + this.form = { + code1: 0, + layerVal: null, + toward: null, + shelfVal: null + } + this.rackOptions = [] + this.filterShelfList = [] this.currentTreeNode = nodeData.raw - console.log('handleTreeNodeClick', nodeData) + + console.log('this.currentTreeNode', this.currentTreeNode) + const currentNode = this.$refs.treeRef.getNode(nodeData) - console.log('currentNode', currentNode) - if (currentNode.level === 1) { - return - } + if (currentNode.level === 1) return + const parentNode = currentNode.parent - const parentLabel = parentNode && parentNode.data && parentNode.data.label - ? parentNode.data.label - : '' + const parentLabel = parentNode?.data?.label || '' + this.selectedValue = parentLabel ? `${parentLabel} - ${nodeData.label}` : nodeData.label - this.selectedValue = parentLabel - ? `${parentLabel} - ${nodeData.label}` - : nodeData.label this.$refs.selectRef.blur() this.getInitBookShelfList(currentNode.data) + // 【必须同步】3D状态,无论是不是地图切换都要更新 if (nodeData.raw.mapType === 1) { this.is3DMap = false } else { this.is3DMap = true + } + + // 【只有地图切换时,跳过请求接口】 + if (this.isMapSwitching) { + console.log('✅ 地图楼层切换,跳过重复请求地图接口') + return + } + + // 【用户手动点击才请求】 + if (this.is3DMap) { this.getMapDetails(nodeData.raw.mapId) } }, - getMapDetails(id) { const params = { 'id': id @@ -608,6 +650,59 @@ export default { // 模拟获取绑定数据 this.fetchBindData(areaFid) }, + // handleLevel(level, levelName) { + // console.log('mapLevel', level) + // console.log('levelName', levelName) + + // // 标记:是地图切换触发的选中,不是用户点击 + // this.isMapSwitching = true + + // // 执行选中树节点 + // this.selectTreeNodeByFloorName(levelName) + + // // 关键:延迟解锁,保证整个流程走完 + // setTimeout(() => { + // this.isMapSwitching = false + // }, 300) + // }, + /** + * 根据楼层名(如 2F)自动选中树节点 + * @param {string} floorName 楼层名 1F / 2F / 3F... + */ + selectTreeNodeByFloorName(floorName) { + if (!floorName || !this.regionTreeData.length || !this.$refs.treeRef) return + + // 去掉 F,匹配树里的楼层名称(根据你的数据结构调整) + const targetFloorName = floorName.replace('F', '').trim() + + // 递归查找树节点 + const targetNode = this.findFloorNodeByName(this.regionTreeData, targetFloorName) + + if (targetNode) { + // 树选中节点 + this.$refs.treeRef.setCurrentKey(targetNode.id) + // 触发点击事件(同步更新页面数据) + this.handleTreeNodeClick(targetNode) + } + }, + + /** + * 递归查找 楼层节点(根据你的树结构) + */ + findFloorNodeByName(treeData, floorName) { + for (const node of treeData) { + // 判断:当前节点是楼层节点 && 节点label包含楼层名(如 2楼 / 2F / 二层) + if (node.floorId && node.label && node.label.includes(floorName)) { + return node + } + // 递归子节点 + if (node.children && node.children.length) { + const res = this.findFloorNodeByName(node.children, floorName) + if (res) return res + } + } + return null + }, fetchBindData(fid) { // 模拟异步请求 setTimeout(() => { diff --git a/src/views/weChatMiniProgram/index.vue b/src/views/weChatMiniProgram/index.vue new file mode 100644 index 0000000..a06307a --- /dev/null +++ b/src/views/weChatMiniProgram/index.vue @@ -0,0 +1,429 @@ + + + + +