This commit is contained in:
yyy 2025-07-15 18:33:23 +08:00
parent 5fdd0f6cd1
commit 6e13f318e5
7 changed files with 393 additions and 212 deletions

View File

@ -4,9 +4,9 @@ NODE_ENV=development
VITE_DEV=true
# 请求路径
# VITE_BASE_URL='http://10.10.7.132:48080'
VITE_BASE_URL='http://10.10.7.132:48080'
# VITE_BASE_URL='http://10.10.100.15:48080'
VITE_BASE_URL='http://10.10.5.5:48080'
# VITE_BASE_URL='http://10.10.5.5:48080'
# 文件上传类型server - 后端上传, client - 前端直连上传,仅支持 S3 服务
VITE_UPLOAD_TYPE=server

View File

@ -1,7 +1,5 @@
import request from '@/config/axios'
//分页查询设备列表 看板信息设备目前用的是这个
export const deviceInformationPage = async (params) => {
return await request.get({ url: `/system/device/information/page`, params })
@ -41,3 +39,6 @@ export const deviceGetInformationList = async (params) => {
export const getMapDeviceImageUrl = async (params) => {
return await request.get({ url: `/system/device/information/getMapImageUrl`, params })
}
export const getWareHouseTakePointList = async (data) => {
return await request.post({ url: `/system/ware/house-take-point/list`, data })
}

View File

@ -265,6 +265,7 @@
<div
class="item-inner-left-bottom-btn"
:style="{ color: item.onlineStatus == 0 ? '#CCCCCC' : '#0D162A' }"
@click="viewDeviceLog"
>
日志查看
</div>
@ -556,12 +557,26 @@ const clockCar = (item) => {
.catch(() => {})
}
//
const goToMap = (item) => {
//
const goMap = (item) => {
if (!item.floor || !item.area) {
message.warning('该车辆未配置地图信息')
return
}
router.push({
name: 'MapPageRealTimeMap',
query: {
id: item.id
floor: item.floor,
area: item.area
}
})
}
const viewDeviceLog = () => {
router.push({
name: 'MapLogQueriesList',
query: {
activeTab: 2 //
}
})
}

View File

@ -44,10 +44,24 @@
/>
</el-form-item>
<el-form-item label="设备IP" v-if="formData.deviceType !== 9">
<el-input v-model="formData.deviceIp" :disabled="false" show-word-limit placeholder="请输入设备ip" maxlength="20" @input="formData.deviceIp=formData.deviceIp.replace(/[^\d.]/g,'')" />
<el-input
v-model="formData.deviceIp"
:disabled="false"
show-word-limit
placeholder="请输入设备ip"
maxlength="20"
@input="formData.deviceIp = formData.deviceIp.replace(/[^\d.]/g, '')"
/>
</el-form-item>
<el-form-item label="端口" v-if="formData.deviceType !== 9">
<el-input v-model="formData.devicePort" :disabled="false" show-word-limit placeholder="请输入端口" maxlength="10" @input="formData.devicePort=formData.devicePort.replace(/[\u4E00-\u9FA5]/g,'')"/>
<el-input
v-model="formData.devicePort"
:disabled="false"
show-word-limit
placeholder="请输入端口"
maxlength="10"
@input="formData.devicePort = formData.devicePort.replace(/[\u4E00-\u9FA5]/g, '')"
/>
</el-form-item>
<el-form-item label="充电桩类型" prop="deviceAttribute" v-if="formData.deviceType == 1">
<el-select v-model="formData.deviceAttribute" clearable placeholder="请选择设备类型">
@ -78,6 +92,31 @@
<el-option :label="'启用'" :value="1" />
</el-select>
</el-form-item>
<el-form-item label="设备取放货点位" v-if="formData.deviceType == 10" required>
<el-select v-model="formData.takePointId" filterable placeholder="请输入取放货点位">
<el-option
v-for="item in takePointList"
:key="item.id"
:label="item.pointName"
:value="item.id"
/>
</el-select>
</el-form-item>
<el-form-item label="检测区点位" v-if="formData.deviceType == 10" required>
<el-select
v-model="formData.checkPointIds"
multiple
filterable
placeholder="请选择检测区点位"
>
<el-option
v-for="item in checkPointList"
:key="item.id"
:label="item.pointName"
:value="item.id"
/>
</el-select>
</el-form-item>
<el-form-item label="设备图标">
<UploadImg v-model="formData.mapImageUrl" :limit="1" />
</el-form-item>
@ -104,9 +143,9 @@
<script lang="ts" setup>
const { t } = useI18n() //
const message = useMessage() //
import * as MapTaskAPi from '@/api/map/mapTask'
import * as DeviceApi from '@/api/device/index'
import { DICT_TYPE, getDictOptions } from '@/utils/dict'
const dialogVisible = ref(false) //
const formLoading = ref(false) // 12
const title = ref('新建') // form
@ -121,11 +160,38 @@ const formData = ref({
deviceEnable: undefined, // 01
devicePort: undefined, //
deviceIp: undefined, //IP
cameraType:undefined, //
deviceLocation:undefined, //
cameraCode:undefined //
cameraType: undefined, //
deviceLocation: undefined, //
cameraCode: undefined, //
takePointId: undefined, //
checkPointIds: [] //
})
//
const takePointList = ref([])
//
const checkPointList = ref([])
//
const getTakePointList = async () => {
try {
takePointList.value = await DeviceApi.getWareHouseTakePointList({ pointType: 1 })
} catch (error) {
console.error('获取取放货点位失败:', error)
takePointList.value = []
}
}
//
const getCheckPointList = async () => {
try {
checkPointList.value = await DeviceApi.getWareHouseTakePointList({ pointType: 0 })
} catch (error) {
console.error('获取检测区点位失败:', error)
checkPointList.value = []
}
}
const formRules = reactive({
deviceType: [{ required: true, message: '设备类型不能为空', trigger: 'blur' }],
deviceNo: [{ required: true, message: '设备编号不能为空', trigger: 'blur' }],
@ -137,35 +203,46 @@ const formRules = reactive({
deviceEnable: [{ required: true, message: '是否启用不能为空', trigger: 'blur' }],
cameraType: [{ required: true, message: '摄像头类型不能为空', trigger: 'blur' }],
cameraCode: [{ required: true, message: '摄像头编号不能为空', trigger: 'blur' }],
takePointId: [{ required: true, message: '取放货点位不能为空', trigger: 'blur' }],
checkPointIds: [{ required: true, message: '检测点不能为空', trigger: 'blur' }]
})
const formRef = ref() // Ref
/** 打开弹窗 */
const open = async (type, id) => {
// console.log(getDictOptions(DICT_TYPE.DEVICE_TYPE))
dialogVisible.value = true
resetForm()
if (id) {
title.value = '编辑'
const data = await DeviceApi.deviceInformationGet({ id })
formData.value = data
if (!formData.value.mapImageUrl) {
DeviceApi.getMapDeviceImageUrl({
deviceType: formData.value.deviceType
}).then((res) => {
// console.log(res)
formData.value.mapImageUrl = res ? res : undefined
})
}
// cameraType
if (formData.value.deviceType !== 9) {
formData.value.cameraType = undefined;
}
await loadDeviceDetail(id)
} else {
title.value = '新建'
}
// getCanUseRobotList()
// getTaskNo()
}
/** 加载设备详情 */
const loadDeviceDetail = async (id) => {
const data = await DeviceApi.deviceInformationGet({ id })
formData.value = data
if (!formData.value.mapImageUrl) {
DeviceApi.getMapDeviceImageUrl({
deviceType: formData.value.deviceType
}).then((res) => {
formData.value.mapImageUrl = res ? res : undefined
})
}
// cameraType
if (formData.value.deviceType !== 9) {
formData.value.cameraType = undefined
}
//
if (formData.value.deviceType === 10) {
await getTakePointList()
await getCheckPointList()
}
}
defineExpose({ open }) // open
@ -196,76 +273,46 @@ const submitForm = async () => {
}
}
//
const deviceTypeChange = (e) => {
const deviceTypeChange = async (e) => {
DeviceApi.getMapDeviceImageUrl({
deviceType: e
}).then((res) => {
// console.log(res)
formData.value.mapImageUrl = res ? res : undefined
})
if (e === 9) {
formData.value.cameraType = '1';
formData.value.cameraType = '1'
} else {
formData.value.cameraType = undefined;
formData.value.cameraType = undefined
}
}
//
const { push } = useRouter()
const taskManagement = () => {
push({ name: 'taskManagementCreateTask' })
}
//
const robotList = ref([])
const getCanUseRobotList = async () => {
robotList.value = await MapTaskAPi.getCanUseRobot()
}
//
const getTaskNo = async () => {
formData.value.taskNo = await MapTaskAPi.getTaskNo()
}
//
const getLocationList = async (type, locationNo) => {
return await MapTaskAPi.getLocationByName({
type, // 12线 3
locationNo
})
}
//
const loading = ref(false)
const releaseRemoteMethod = async (query, item) => {
if (query) {
loading.value = true
item.releaseList = await getLocationList(item.releaseType, query)
loading.value = false
} else {
item.releaseList = []
}
}
//
const takeRemoteMethod = async (query, item) => {
if (query) {
item.takeList = await getLocationList(item.takeType, query)
} else {
item.takeList = []
// (10)
if (e === 10) {
await getTakePointList()
await getCheckPointList()
//
formData.value.takePointId = undefined
formData.value.checkPointIds = []
}
}
/** 重置表单 */
const resetForm = () => {
formData.value = {
deviceType: undefined, //id
deviceType: undefined, //
deviceNo: undefined, //
macAddress: undefined, //mac
mapImageUrl: undefined, //
pictureConfig: undefined, // 12 3
url: undefined, //
deviceAttribute: undefined,//
cameraType:undefined, //
deviceLocation:undefined, //
cameraCode:undefined, //
deviceAttribute: undefined,
deviceEnable: undefined, // 01
devicePort: undefined, //
deviceIp: undefined, //IP
cameraType: undefined, //
deviceLocation: undefined, //
cameraCode: undefined, //
takePointId: undefined, //
checkPointIds: [] //
}
formRef.value?.resetFields()

View File

@ -43,91 +43,118 @@
</div>
</ContentWrap>
<div class="new-list-box-all">
<div class="new-list-box">
<div class="item" v-for="(item, index) in list" :key="index">
<div class="item-top">
<div class="item-inner-left-name">
<div class="item-inner-left-name-inner">
{{ filterTypeFun(item.deviceType, typeList) }} {{ item.deviceNo }}
<el-skeleton :rows="6" animated :loading="loading" :throttle="500">
<template #template>
<div style="padding: 20px">
<el-skeleton-item variant="h1" style="width: 50%" />
<div style="display: flex; justify-content: space-between; margin-top: 20px">
<div style="width: 30%">
<el-skeleton-item variant="image" style="width: 100%; height: 150px" />
</div>
<div style="width: 65%">
<el-skeleton-item variant="text" style="width: 100%; margin-bottom: 10px" />
<el-skeleton-item variant="text" style="width: 100%; margin-bottom: 10px" />
<el-skeleton-item variant="text" style="width: 100%; margin-bottom: 10px" />
<el-skeleton-item variant="text" style="width: 100%" />
</div>
</div>
<div class="item-inner-right-top">
<div class="swiper-item-box-top-msg">
<el-dropdown>
<div style="flex-shrink: 0">
<el-icon size="20px"><MoreFilled /></el-icon>
</div>
</template>
<template #default>
<div class="new-list-box">
<div class="item" v-for="(item, index) in list" :key="index">
<div class="item-top">
<div class="item-inner-left-name">
<div class="item-inner-left-name-inner">
{{ filterTypeFun(item.deviceType, typeList) }} {{ item.deviceNo }}
</div>
</div>
<div class="item-inner-right-top">
<div class="swiper-item-box-top-msg">
<el-popover placement="bottom" trigger="click">
<template #reference>
<div style="flex-shrink: 0; cursor: pointer">
<el-icon size="20px"><MoreFilled /></el-icon>
</div>
</template>
<div class="popover-menu">
<div
class="popover-menu-item"
@click="openForm('update', item.id)"
v-hasPermi="['device:index:edit']"
>编辑</div
>
<div
class="popover-menu-item"
@click="clockDevice(item)"
v-hasPermi="['device:index:lock']"
>{{ item.deviceEnable == 0 ? '启用' : '禁用' }}</div
>
<div
class="popover-menu-item"
@click="deleteCar(item.id)"
v-hasPermi="['device:index:delete']"
>删除</div
>
</div>
</el-popover>
</div>
<template #dropdown>
<el-dropdown-menu>
<el-dropdown-item
@click="openForm('update', item.id)"
v-hasPermi="['device:index:edit']"
>编辑</el-dropdown-item
>
<el-dropdown-item
@click="clockDevice(item)"
v-hasPermi="['device:index:lock']"
>{{ item.deviceEnable == 0 ? '启用' : '禁用' }}</el-dropdown-item
>
<el-dropdown-item
@click="deleteCar(item.id)"
v-hasPermi="['device:index:delete']"
>删除</el-dropdown-item
>
</el-dropdown-menu>
</template>
</el-dropdown>
</div>
</div>
</div>
<div class="item-inner">
<div class="item-inner-left">
<div class="item-inner-left-img-box">
<el-image
style="width: 100%; height: 100%"
:src="item.url"
:fit="'fill'"
v-if="item.pictureConfig != 3"
/>
<div class="item-inner-left-img-box-no" v-else>
<span>不显示图片</span>
</div>
</div>
<div class="item-inner-left-bottom">
<div class="item-inner-left-bottom-btn" @click="goMap(item)"> 地图定位 </div>
<div class="item-inner-left-bottom-btn"> 日志查看 </div>
</div>
</div>
<div class="item-inner-right-msg">
<div class="item-inner-right-msg-item m-b-10">
<div class="item-inner-right-msg-item-name">编号</div>
<div class="item-inner-right-msg-item-value overhide">{{ item.deviceNo || '' }}</div>
</div>
<div class="item-inner-right-msg-item m-b-10">
<div class="item-inner-right-msg-item-name overhide">是否启用</div>
<div class="item-inner-right-msg-item-value">
<span v-if="item.deviceEnable == 0" style="color: #c60606">禁用</span>
<span v-if="item.deviceEnable == 1" style="color: #4dc606">启用</span>
<div class="item-inner">
<div class="item-inner-left">
<div class="item-inner-left-img-box">
<el-image
style="width: 100%; height: 100%"
:src="item.url"
:fit="'fill'"
v-if="item.pictureConfig != 3"
/>
<div class="item-inner-left-img-box-no" v-else>
<span>不显示图片</span>
</div>
</div>
<div class="item-inner-left-bottom">
<div class="item-inner-left-bottom-btn" @click="goMap(item)"> 地图定位 </div>
<div class="item-inner-left-bottom-btn" @click="viewDeviceLog(item)">
日志查看
</div>
</div>
</div>
</div>
<div class="item-inner-right-msg-item m-b-10">
<div class="item-inner-right-msg-item-name">位置</div>
<div class="item-inner-right-msg-item-value" v-if="item.deviceLocation !== null"
>{{ item.deviceLocation || '' }}
</div>
</div>
<div class="item-inner-right-msg-item">
<div class="item-inner-right-msg-item-name overhide">最后通讯时间</div>
<div
class="item-inner-right-msg-item-value overhide"
v-if="item.deviceLastTime !== null"
>{{ item.deviceLastTime || '' }}
<div class="item-inner-right-msg">
<div class="item-inner-right-msg-item m-b-10">
<div class="item-inner-right-msg-item-name">编号</div>
<div class="item-inner-right-msg-item-value overhide">{{
item.deviceNo || ''
}}</div>
</div>
<div class="item-inner-right-msg-item m-b-10">
<div class="item-inner-right-msg-item-name overhide">是否启用</div>
<div class="item-inner-right-msg-item-value">
<span v-if="item.deviceEnable == 0" style="color: #c60606">禁用</span>
<span v-if="item.deviceEnable == 1" style="color: #4dc606">启用</span>
</div>
</div>
<div class="item-inner-right-msg-item m-b-10">
<div class="item-inner-right-msg-item-name">位置</div>
<div class="item-inner-right-msg-item-value" v-if="item.deviceLocation !== null"
>{{ item.deviceLocation || '' }}
</div>
</div>
<div class="item-inner-right-msg-item">
<div class="item-inner-right-msg-item-name overhide">最后通讯时间</div>
<div
class="item-inner-right-msg-item-value overhide"
v-if="item.deviceLastTime !== null"
>{{ item.deviceLastTime || '' }}
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</template>
</el-skeleton>
</div>
<createEditDialog ref="createEditDialogRef" @success="initFun()" />
</template>
@ -149,6 +176,7 @@ const message = useMessage() // 消息弹窗
const router = useRouter() //
const createEditDialogRef = ref(null)
const list = ref([])
const loading = ref(true) // loading
const queryParams = reactive({
deviceNo: undefined,
deviceType: undefined
@ -156,25 +184,11 @@ const queryParams = reactive({
const activeName = ref('-1')
const handleClick = (tab, event) => {
loading.value = true // loading
queryParams.deviceType = tab.props.name != -1 ? tab.props.name : undefined
getCarList()
}
const typeList = ref([])
const typeListCache = new Map()
const getTypeList = () => {
const cacheKey = 'device_type_list'
if (typeListCache.has(cacheKey)) {
typeList.value = typeListCache.get(cacheKey)
} else {
const options = getDictOptions(DICT_TYPE.DEVICE_TYPE) || []
typeList.value = [{ label: '全部', value: '-1' }, ...options]
typeListCache.set(cacheKey, typeList.value)
}
getRobotInformationStatistics()
}
//type
const filterTypeFun = (type, list) => {
if (!list?.length) return type
@ -189,7 +203,7 @@ const goMap = (item) => {
return
}
router.push({
path: '/mapPage/realTimeMap',
name: 'MapPageRealTimeMap',
query: {
floorArea: JSON.stringify([item.floor, item.positionMapId])
}
@ -199,22 +213,29 @@ const goMap = (item) => {
const timerRef = ref(null)
//
const getCarList = debounce(async () => {
loading.value = true // loading
try {
list.value = await DeviceApi.deviceGetInformationList(queryParams)
} catch (error) {
console.error('获取设备列表失败:', error)
} finally {
loading.value = false // loading
}
}, 300)
const carStatistics = ref({
standby: 0,
inTask: 0,
doLock: 0,
offline: 0,
fault: 0,
charge: 0,
total: 0
})
const typeList = ref([])
const getTypeList = () => {
const res = getDictOptions(DICT_TYPE.DEVICE_TYPE) || []
const options = res.map((item) => {
return {
label: item.label,
value: item.value
}
})
typeList.value = [{ label: '全部', value: '-1' }, ...options]
getRobotInformationStatistics()
}
//
const getRobotInformationStatistics = async () => {
@ -227,7 +248,8 @@ const getRobotInformationStatistics = async () => {
let total = 0
typeList.value.forEach((item) => {
const matchItem = res.find((resItem) => item.value === resItem.deviceType)
// valuedeviceType
const matchItem = res.find((resItem) => String(resItem.deviceType) === item.value)
item.number = matchItem ? Number(matchItem.number) : 0
if (item.value !== '-1') {
total += item.number
@ -238,6 +260,7 @@ const getRobotInformationStatistics = async () => {
console.error('获取设备统计失败:', error)
}
}
const clockDevice = (item) => {
let valueStr = item.deviceEnable == 1 ? '禁用' : '启用'
let data = JSON.parse(JSON.stringify(item))
@ -248,6 +271,7 @@ const clockDevice = (item) => {
type: 'warning'
})
.then(() => {
loading.value = true // loading
DeviceApi.deviceInformationUpdate(data).then((res) => {
initFun()
message.success(`${valueStr}成功`)
@ -267,6 +291,7 @@ const deleteCar = (id) => {
type: 'warning'
})
.then(() => {
loading.value = true // loading
DeviceApi.deleteDeviceInformation(id).then((res) => {
initFun()
message.success('删除成功')
@ -275,24 +300,6 @@ const deleteCar = (id) => {
.catch(() => {})
}
const clockCar = (item) => {
// let valueStr = item.robotTaskModel == 1 ? '' : ''
// let data = JSON.parse(JSON.stringify(item))
// data.robotTaskModel = item.robotTaskModel == 1 ? 0 : 1
// ElMessageBox.confirm(`${valueStr}?`, '', {
// confirmButtonText: '',
// cancelButtonText: '',
// type: 'warning'
// })
// .then(() => {
// DeviceApi.robotInformationUpdate(data).then((res) => {
// getCarList()
// message.success(`${valueStr}`)
// })
// })
// .catch(() => {})
}
//
const goToMap = (item) => {
router.push({
@ -303,7 +310,14 @@ const goToMap = (item) => {
})
}
const viewDeviceLog = (item) => {
router.push({
name: 'MapLogQueriesList'
})
}
const initFun = () => {
loading.value = true // loading
getCarList()
getTypeList()
}
@ -364,6 +378,23 @@ onBeforeRouteLeave((to, from, next) => {
box-shadow: none !important;
}
/* popover菜单样式 */
.popover-menu {
padding: 5px 0;
}
.popover-menu-item {
padding: 8px 12px;
cursor: pointer;
font-size: 14px;
color: #333;
transition: background-color 0.3s;
&:hover {
background-color: #f5f7fa;
color: #1677ff;
}
}
.swiper-container {
width: calc(100% - 60px);
padding: 0 30px;

View File

@ -336,6 +336,7 @@ import { dateFormatter } from '@/utils/formatTime'
defineOptions({ name: 'MapLogQueriesList' })
const message = useMessage() //
const route = useRoute() //
const activeName = ref('1') //tab
@ -459,9 +460,30 @@ const getCanUseRobotList = async () => {
robotList.value = await MapTaskAPi.getCanUseRobot()
}
// URL
const handleRouteParams = () => {
const { query } = route
//
if (query.activeTab) {
activeName.value = query.activeTab
}
}
/** 初始化 **/
onMounted(() => {
getOperationLogList()
// URL
handleRouteParams()
//
if (activeName.value === '1') {
getOperationLogList()
} else if (activeName.value === '2') {
getCarLogList()
} else if (activeName.value === '3') {
getTaskLogList()
}
getCanUseRobotList()
})
</script>

View File

@ -34,7 +34,7 @@
<script setup>
import indexPage from './components/indexPage.vue'
import createTaskDialog from './components/createTaskDialog.vue'
import { ref, defineComponent, reactive, nextTick, onMounted } from 'vue'
import { ref, defineComponent, reactive, nextTick, onMounted, watch } from 'vue'
import * as MapApi from '@/api/map/map'
import download from '@/utils/download'
import { ElMessage, ElMessageBox } from 'element-plus'
@ -64,16 +64,47 @@ const getList = async () => {
}))
}))
// floorArea
const { query } = route
if (query.floorArea) {
try {
const [floor, mapId] = JSON.parse(query.floorArea)
if (floor && mapId) {
mapValue.value = [String(floor), String(mapId)]
handleChangeMap(mapValue.value)
return
}
} catch (error) {
console.error('解析floorArea参数失败:', error)
}
}
// floorarea
if (query.floor && query.area) {
// ID
const floorItem = list.value.find((item) => item.floor === query.floor)
if (floorItem && floorItem.children) {
const areaItem = floorItem.children.find((item) => item.area === query.area)
if (areaItem) {
mapValue.value = [String(query.floor), String(areaItem.id)]
handleChangeMap(mapValue.value)
return
}
}
}
// mapId
if (query.mapId) {
let item = findItemById(query.mapId)
if (item) {
mapValue.value = [String(item.floor), String(item.id)]
handleChangeMap(mapValue.value)
return
}
}
if (mapValue.value.length) {
handleChangeMap(mapValue.value)
} else {
// 使
if (list.value.length > 0 && list.value[0].children && list.value[0].children.length > 0) {
mapValue.value = [list.value[0].value, list.value[0].children[0].value]
indexPageRef.value.getMapData(JSON.parse(JSON.stringify(list.value[0].children[0])))
}
@ -83,13 +114,17 @@ const getList = async () => {
const handleChangeMap = async (e) => {
let item = findItemById(e[1])
indexPageRef.value.getMapData(item)
router.replace({
name: 'MapPageRealTimeMap',
query: {
mapId: item.id
}
})
if (item) {
indexPageRef.value.getMapData(item)
router.replace({
name: 'MapPageRealTimeMap',
query: {
mapId: item.id
}
})
} else {
message.warning('未找到对应地图')
}
}
//
@ -125,6 +160,8 @@ const emergencyStop = async () => {
}
const getStopOrRestore = async () => {
if (!mapValue.value || mapValue.value.length < 2) return
let res = await MapApi.getMapIsStop({
id: mapValue.value[1]
})
@ -167,7 +204,35 @@ function findItemById(targetId) {
return null
}
const { query } = useRoute() //
//
watch(
() => route.query,
(newQuery) => {
if (newQuery.floorArea && list.value.length > 0) {
try {
const [floor, mapId] = JSON.parse(newQuery.floorArea)
if (floor && mapId) {
mapValue.value = [String(floor), String(mapId)]
handleChangeMap(mapValue.value)
}
} catch (error) {
console.error('解析floorArea参数失败:', error)
}
} else if (newQuery.floor && newQuery.area && list.value.length > 0) {
// floorarea
const floorItem = list.value.find((item) => item.floor === newQuery.floor)
if (floorItem && floorItem.children) {
const areaItem = floorItem.children.find((item) => item.area === newQuery.area)
if (areaItem) {
mapValue.value = [String(newQuery.floor), String(areaItem.id)]
handleChangeMap(mapValue.value)
}
}
}
},
{ deep: true }
)
onMounted(() => {
getList()
})