This commit is contained in:
yyy 2025-03-05 19:07:40 +08:00
commit cdc4ec025e

View File

@ -3,7 +3,7 @@
class="affix-container" class="affix-container"
id="indexpage-container" id="indexpage-container"
:style="{ :style="{
height: heightVal * radio + 'px', height: heightVal + 'px',
cursor: isDrag ? 'pointer' : 'default', cursor: isDrag ? 'pointer' : 'default',
scale: isSizeRaio, scale: isSizeRaio,
transformOrigin: '0 0' transformOrigin: '0 0'
@ -42,7 +42,7 @@
:x2="Number(item.endPointX) * radio" :x2="Number(item.endPointX) * radio"
:y2="Number(item.endPointY) * radio" :y2="Number(item.endPointY) * radio"
:stroke="item.isSelect ? '#f48924' : '#00329F'" :stroke="item.isSelect ? '#f48924' : '#00329F'"
:stroke-width="5 * radio" :stroke-width="(5 / nowObject.showYamlJson.resolution / 100 * radio)>1.5?(5 / nowObject.showYamlJson.resolution / 100 * radio):1.5"
:marker-start="item.direction === 2 ? 'url(#double-arrow-start)' : ''" :marker-start="item.direction === 2 ? 'url(#double-arrow-start)' : ''"
marker-end="url(#single-arrow)" marker-end="url(#single-arrow)"
@click="handleChooseRoute(item, index)" @click="handleChooseRoute(item, index)"
@ -51,7 +51,7 @@
:d="getLineMidArrowPath(item)" :d="getLineMidArrowPath(item)"
stroke="none" stroke="none"
fill="black" fill="black"
stroke-width="4" :stroke-width="(5 / nowObject.showYamlJson.resolution / 100 * radio)>1.5?(5 / nowObject.showYamlJson.resolution / 100 * radio):1.5"
:marker-start="item.direction === 2 ? 'url(#backward-arrow)' : ''" :marker-start="item.direction === 2 ? 'url(#backward-arrow)' : ''"
:marker-end=" :marker-end="
item.direction === 2 ? 'url(#forward-arrow)' : 'url(#forward-arrow)' item.direction === 2 ? 'url(#forward-arrow)' : 'url(#forward-arrow)'
@ -62,7 +62,7 @@
<path <path
:d="getCurvePath(item)" :d="getCurvePath(item)"
:stroke="item.isSelect ? '#f48924' : '#00329F'" :stroke="item.isSelect ? '#f48924' : '#00329F'"
:stroke-width="5 * radio" :stroke-width="(5 / nowObject.showYamlJson.resolution / 100 * radio)>1.5?(5 / nowObject.showYamlJson.resolution / 100 * radio):1.5"
fill="none" fill="none"
:marker-start="item.direction === 2 ? 'url(#backward-arrow)' : ''" :marker-start="item.direction === 2 ? 'url(#backward-arrow)' : ''"
:marker-end=" :marker-end="
@ -84,8 +84,11 @@
:style="{ :style="{
left: item.realX * radio + 'px', left: item.realX * radio + 'px',
top: item.realY * radio + 'px', top: item.realY * radio + 'px',
width: legendObj.carShow ? 40 * radio + 'px' : '0', width: legendObj.carShow ? carWidth / nowObject.showYamlJson.resolution / 100 * radio + 'px' : '0',
height: legendObj.carShow ? 22 * radio + 'px' : '0' height: legendObj.carShow ? carHeight / nowObject.showYamlJson.resolution / 100 * radio + 'px' : '0',
transform: 'rotate(' + radianToDegree(item.data.pose2d.yaw) + 'deg)',
transition: 'all 0.4s linear 0s',
zIndex: 9999
}" }"
> >
<img <img
@ -238,8 +241,8 @@
class="indexpage-container-box-point-item-inner" class="indexpage-container-box-point-item-inner"
v-if="item.type == 5" v-if="item.type == 5"
:style="{ :style="{
width: 150 * radio + 'px', width: item.locationWide / nowObject.showYamlJson.resolution / 100 * radio + 'px',
height: 150 * radio + 'px' height: item.locationDeep / nowObject.showYamlJson.resolution / 100 * radio + 'px'
}" }"
> >
<div> <div>
@ -259,8 +262,8 @@
class="indexpage-container-box-point-item-inner" class="indexpage-container-box-point-item-inner"
v-if="item.type == 6" v-if="item.type == 6"
:style="{ :style="{
width: 150 * radio + 'px', width: item.locationWide / nowObject.showYamlJson.resolution / 100 * radio + 'px',
height: 150 * radio + 'px' height: item.locationDeep / nowObject.showYamlJson.resolution / 100 * radio + 'px'
}" }"
> >
<div> <div>
@ -279,14 +282,14 @@
<el-tooltip <el-tooltip
class="box-item" class="box-item"
effect="dark" effect="dark"
:content="item.sortNum" :content="item.sortNum + ''"
placement="top" placement="top"
v-if="item.type == 1" v-if="item.type == 1"
> >
<div <div
:style="{ :style="{
width: 10 * radio + 'px', width: item.locationWide / nowObject.showYamlJson.resolution / 100 * radio + 'px',
height: 10 * radio + 'px', height: item.locationDeep / nowObject.showYamlJson.resolution / 100 * radio + 'px',
background: '#000', background: '#000',
borderRadius: '50%' borderRadius: '50%'
}" }"
@ -396,7 +399,7 @@
/> />
</div> </div>
</div> </div>
<storeDialog ref="storeDialogRef" @success="getList" /> <storeDialog ref="storeDialogRef" @success="emitParent" />
<carDialog ref="carDialogRef" /> <carDialog ref="carDialogRef" />
</template> </template>
@ -423,32 +426,23 @@ const carDialogRef = ref(null)
const socketClient = ref(null) const socketClient = ref(null)
const router = useRouter() // const router = useRouter() //
const emit = defineEmits(['transmitMapId']) const emit = defineEmits(['transmitMapId'])
const storeDialogRef = ref(null) const storeDialogRef = ref(null) //
const list = ref([]) const list = ref([])
const nowObject = ref(null) const nowObject = ref(null) //
const testCarList = ref([]) const testCarList = ref([]) //
const carPointListFun = () => { const carWidth = ref(60)
let testJson = { const carHeight = ref(32)
type: 'map_push',
content:
'{"d0:65:78:c4:af:cc":"{\\"id\\":1,\\"macAddress\\":\\"d0:65:78:c4:af:cc\\",\\"robotModelNumber\\":\\"A-1\\",\\"pose2d\\":{\\"y\\":\\"1\\",\\"x\\":\\"2\\",\\"yaw\\":\\"30\\",\\"floor\\":\\"1\\",\\"area\\":\\"A区\\",\\"bat_soc\\":\\"40\\"}}"}'
}
let data = JSON.parse(testJson.content)
// console.log("============",data)
let dataList = []
for (let key in data) {
dataList.push({
macAddress: key,
data: JSON.parse(data[key])
})
}
// console.log('=====', dataList)
testCarList.value = dataList
// let data2 = JSON.parse(data['d0:65:78:c4:af:cc']) const convertActualToBrowser = (pointX, pointY) => {
// console.log(data2)   const y1 = Number(nowObject.value.showYamlJson.origin[1]) + Number(nowObject.value.showYamlJson.height) * Number(nowObject.value.showYamlJson.resolution)
}   let x = Math.max(Number(pointX) - Number(nowObject.value.showYamlJson.origin[0]), 0)
  let y = Math.max(y1 - Number(pointY), 0)
  return {
    x :(x / nowObject.value.showYamlJson.resolution) - (carWidth.value / nowObject.value.showYamlJson.resolution / 100/2),
    y: (y / nowObject.value.showYamlJson.resolution) - (carHeight.value / nowObject.value.showYamlJson.resolution / 100/2)
  }
}
// //
const isDrag = ref(false) const isDrag = ref(false)
const changeIsDrag = () => { const changeIsDrag = () => {
@ -462,6 +456,7 @@ const changeIsDrag = () => {
}) })
} }
//线
const handleChooseRoute = (val, i) => { const handleChooseRoute = (val, i) => {
// console.log('============================', val) // console.log('============================', val)
if (lineList.value.length) { if (lineList.value.length) {
@ -603,36 +598,7 @@ const toggleFullScreen = () => {
} }
}) })
} }
//
const getList = async () => {
let data = await MapApi.getPositionMapGetMap()
let mapList = []
for (let key in data) {
mapList.push({
floor: key,
label: key + '层',
value: key,
children: data[key]
})
}
if (mapList.length) {
mapList.forEach((item) => {
if (item.children.length) {
item.children.forEach((child) => {
child.label = child.area
child.value = child.id
})
}
})
}
list.value = mapList
// console.log(list.value, data)
//
if (data[1][0]) {
getMapData(data[1][0])
}
}
// //
const storeClick = async (item) => { const storeClick = async (item) => {
// console.log(item) // console.log(item)
@ -660,7 +626,7 @@ const getPositionMapListFun = async (positionMapId) => {
// console.log(data) // console.log(data)
pointList.value = data pointList.value = data
console.log('=======================', pointList.value) // console.log('=======================', pointList.value)
pointList.value.forEach((item) => { pointList.value.forEach((item) => {
if (item.type === 1) { if (item.type === 1) {
item.locationDeep = 40 item.locationDeep = 40
@ -684,24 +650,7 @@ const getPositionMapListFun = async (positionMapId) => {
} else if (item.type === 7) { } else if (item.type === 7) {
} }
}) })
// let lineStyle = calculateDistanceAndAngle(
// {
// left: pointList.value[0].locationX,
// top: pointList.value[0].locationY
// },
// {
// left: pointList.value[1].locationX,
// top: pointList.value[1].locationY
// }
// )
// console.log(lineStyle)
// lineList.value = [
// {
// ...lineStyle,
// color: '#1677ff',
// height: 2
// }
// ]
} }
const draggableElement = ref(null) const draggableElement = ref(null)
const resetPosition = () => { const resetPosition = () => {
@ -789,7 +738,7 @@ const linkWebSocket = (url) => {
// //
if (jsonMsg.type == 'map_push') { if (jsonMsg.type == 'map_push') {
let data = JSON.parse(jsonMsg.content) let data = JSON.parse(jsonMsg.content)
console.log("======车位点======",data) console.log('======车位点======', data)
let dataList = [] let dataList = []
for (let key in data) { for (let key in data) {
dataList.push({ dataList.push({
@ -799,6 +748,7 @@ const linkWebSocket = (url) => {
} }
// console.log('=====', dataList) // console.log('=====', dataList)
testCarList.value = dataList testCarList.value = dataList
computedRatio()
} }
// //
if (jsonMsg.type == 'agv_warn') { if (jsonMsg.type == 'agv_warn') {
@ -807,18 +757,29 @@ const linkWebSocket = (url) => {
h( h(
'div', 'div',
{ {
style:'background-color: #C60606;', style: 'background-color: #C60606;'
}, },
[ [
h('span', { style: 'color: rgba(255,255,255,0.88);font-size: 14px;' }, `${JSON.parse(jsonMsg.content)}`), h(
h('span', {onClick: () => lookError(), style: 'color: rgba(255,255,255,0.88);font-size: 14px;cursor: pointer;text-decoration-line: underline;margin-left: 32px;' }, '详情'), 'span',
{ style: 'color: rgba(255,255,255,0.88);font-size: 14px;' },
`${JSON.parse(jsonMsg.content)}`
),
h(
'span',
{
onClick: () => lookError(),
style:
'color: rgba(255,255,255,0.88);font-size: 14px;cursor: pointer;text-decoration-line: underline;margin-left: 32px;'
},
'详情'
)
] ]
), ),
showClose: false, showClose: false,
duration: 3000, // duration: 3000, //
type: 'info', type: 'info',
customClass: 'indexpage-custom-message-style', customClass: 'indexpage-custom-message-style'
}) })
} }
}) })
@ -839,9 +800,13 @@ const sendMessage = () => {
const disconnect = () => { const disconnect = () => {
socketClient.value.disconnect() socketClient.value.disconnect()
} }
const emitParent = () => {
getMapData(nowObject.value)
}
// //
const getMapData = async (item) => { const getMapData = async (item) => {
// console.log('============', JSON.parse(item.yamlJson)) // console.log('============', JSON.parse(item.yamlJson))
testCarList.value = []
nowObject.value = JSON.parse(JSON.stringify(item)) nowObject.value = JSON.parse(JSON.stringify(item))
nowObject.value.showYamlJson = JSON.parse(item.yamlJson) nowObject.value.showYamlJson = JSON.parse(item.yamlJson)
let websoketUrl = `${replaceHttpWithWs(import.meta.env.VITE_BASE_URL)}/infra/ws?type=map&floor=${nowObject.value.floor}&area=${nowObject.value.area}` let websoketUrl = `${replaceHttpWithWs(import.meta.env.VITE_BASE_URL)}/infra/ws?type=map&floor=${nowObject.value.floor}&area=${nowObject.value.area}`
@ -861,6 +826,13 @@ const getMapData = async (item) => {
computedRatio() computedRatio()
getMapLineList() getMapLineList()
} }
//
const radianToDegree = (radian) =>{
//
const degree = radian * (180 / Math.PI);
// 'deg' CSS
return `${degree}`;
}
const heightVal = ref(0) const heightVal = ref(0)
const widthVal = ref(0) const widthVal = ref(0)
const radio = ref(1) const radio = ref(1)
@ -873,17 +845,12 @@ const computedRatio = () => {
// console.log("",JSON.parse(nowObject.value.yamlJson)) // console.log("",JSON.parse(nowObject.value.yamlJson))
if (testCarList.value.length) { if (testCarList.value.length) {
testCarList.value.forEach((item) => { testCarList.value.forEach((item) => {
console.log('dayin', item)
item.originWidth = width item.originWidth = width
item.originHeight = height item.originHeight = height
item.origin = JSON.parse(nowObject.value.yamlJson).origin item.origin = JSON.parse(nowObject.value.yamlJson).origin
item.realX = convertToFrontendCoordinates(item.origin, width, height, [ item.realX = convertActualToBrowser(item.data.pose2d.x, item.data.pose2d.y).x
item.data.pose2d.x, item.realY = convertActualToBrowser(item.data.pose2d.x, item.data.pose2d.y).y
item.data.pose2d.y
]).left
item.realY = convertToFrontendCoordinates(item.origin, width, height, [
item.data.pose2d.x,
item.data.pose2d.y
]).top
}) })
// console.log('', testCarList.value) // console.log('', testCarList.value)
} }
@ -918,6 +885,7 @@ const computedRatio = () => {
}) })
} }
// 线
const getMapLineList = () => { const getMapLineList = () => {
MapApi.mapLineListGet({ positionMapId: nowObject.value.id }).then((res) => { MapApi.mapLineListGet({ positionMapId: nowObject.value.id }).then((res) => {
// console.log(res) // console.log(res)
@ -925,6 +893,7 @@ const getMapLineList = () => {
}) })
} }
//
const getImageSize = (url) => { const getImageSize = (url) => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const img = new Image() const img = new Image()
@ -1022,7 +991,6 @@ const observeWidthChange = (id, callback) => {
let stopObserving let stopObserving
defineExpose({ getMapData }) // open defineExpose({ getMapData }) // open
onMounted(() => { onMounted(() => {
// carPointListFun()
// getList() // getList()
window.addEventListener('resize', computedRatio) window.addEventListener('resize', computedRatio)
stopObserving = observeWidthChange('indexpage-container', (newWidth) => { stopObserving = observeWidthChange('indexpage-container', (newWidth) => {
@ -1137,11 +1105,9 @@ onUnmounted(() => {
position: fixed; position: fixed;
bottom: 26px; bottom: 26px;
z-index: 999; z-index: 999;
} }
.affix-container-left-box { .affix-container-left-box {
width: 144px; width: 144px;
} }
.affix-container-left-box-item-box { .affix-container-left-box-item-box {
width: 100%; width: 100%;
@ -1212,6 +1178,4 @@ onUnmounted(() => {
flex-shrink: 0; flex-shrink: 0;
margin-left: 8px; margin-left: 8px;
} }
</style> </style>