headLeft.vue 5.33 KB
<template>
	<div>
		<div class="title-text">第一层</div>
		<div style="width: 100%; height: 80%; position: relative; left: 0vw; top: 3vw;">
			<div class="tishenji_one">
				<div class="ne-one" style="font-size:1.2VW;font-weight:600;">
					提升机
				</div>
				<div style="width:100%;height:18%;border: 1px solid #000;"></div>
				<div style="width:100%;height:56%;display: flex;">
					<div class="lineOne" style="font-size:1.2VW;font-weight:600;">输送线</div>
					<div class="lineTwo" style="font-size:1.2VW;font-weight:600;">输送线</div>
				</div>
			</div>
			<div id="bubble-container"></div>
		</div>
		<div style="color: white;margin:2vh 0 0 7vw;display: flex;">
			<div
				style="display: flex;
                            justify-content: flex-start;
                            align-items: center;"
			>
				<div style="width: 1vw;height: 1vw;background: #98afdb;"></div>
				<div
					style=" font-size: 1vw;
                                       width: 5vw;
                                        margin-left: 0.3vw; "
				>
					过道
				</div>
			</div>

			<div
				style="display: flex;
                            justify-content: flex-start;
                            align-items: center;"
			>
				<div style="width: 1vw;height: 1vw;background: #006fdf;"></div>
				<div
					style=" font-size: 1vw;
                                        width: 3vw;
                                        margin-left: 0.3vw; "
				>
					库位
				</div>
			</div>
			<div
				style="display: flex;
                            justify-content: flex-start;
                            align-items: center;"
			>
				<div style="width: 1vw;height: 1vw;background: #A0169D;"></div>
				<div
					style=" font-size: 1vw;
                                        width: 5vw;
                                        margin-left: 0.3vw; "
				>
					行走路线
				</div>
			</div>
		</div>
	</div>
</template>

<script>
export default {
	data() {
		return {
			sysinfo: [],
		}
	},
	methods: {
		sed(data) {
			data.forEach((x) => {
				if (x.status == 0) {
					x.status = '待机'
				} else if (x.status == 1) {
					x.status = '任务执行中'
				} else if (x.status == 3) {
					x.status = '错误'
				} else if (x.status == 4) {
					x.status = '充电'
				}
			})
			this.agvLineData = data
			var agvLineDatas = this.agvLineData

			if (agvLineDatas) {
				function formatMarkInfo(agvLineDatas) {
					return agvLineDatas.map((item) => ({
						id: `a_${item.barCode}`,
						taskNumber: item.taskNo,
						carCode: item.fwsCode,
						speed: item.speed,
						status: item.status,
						// // startLandmark: item.startLandmark,
						// // endLandmark: item.endLandmark,
						battery: item.powerLevel,
					}))
				}
				console.log(formatMarkInfo(agvLineDatas), 'formatMarkInfo(agvLineDatas)')

				var markInfos = formatMarkInfo(agvLineDatas)
				window.findMarkInfo(markInfos, this.sysinfo)
				this.sysinfo = markInfos
			}
			let temp = data.map((item) => item.taskPathPoints.map((point) => point.barcode))
			// 1. 将数组 b 中所有需要匹配的 id 提取出来,存入一个 Set 中,以提高查找效率
			const idsToUpdate = new Set()
			temp.forEach((pair) => {
				pair.forEach((id) => {
					idsToUpdate.add(id)
				})
			})

			// 2. 遍历 coordinatelist 数组
			window.coordinatelist.forEach((item) => {
				// 3. 使用 Set.has() 方法检查 id 是否存在,这一步非常快
				if (item && idsToUpdate.has(item.id)) {
					// 4. 如果存在,就为该对象添加 bgColor 属性
					item.bgcolor = '#A0169D'
				} else {
					item.bgcolor = ''
				}
			})

			// 2. 【核心修复】重新获取更新后的数据,并调用渲染函数
			let coordinatelist = window.coordinatelist
			let agvMarkList = []
			coordinatelist.forEach((i) => {
				// 这里的计算逻辑必须和 mounted 中保持一致
				agvMarkList.push({ ...i, top: i.y * 1.3 + 'vw', left: i.x * 1.3 + 2 + 'vw' })
			})
			// 再次调用初始化函数,让它根据新数据重新渲染
			window.initMarksLine('#bubble-container', agvMarkList)
		},
	},
	mounted() {
		debugger
		let coordinatelist = window.coordinatelist
		let agvMarkList = []
		coordinatelist.forEach((i) => {
			agvMarkList.push({ ...i, top: i.y * 1.3 + 'vw', left: i.x * 1.3 + 2 + 'vw' })
		})
		window.initMarksLine('#bubble-container', agvMarkList)
	},
}
</script>

<style>
.title-text {
	width: 100%;
	height: 4vh;
	font-size: 3vh;
	font-weight: 600;
	color: #fff;
	text-align: center;
}
.tishenji_one {
	width: 3.9vw;
	height: 15vh;
	position: relative;
	/* font-size: 1.3vw; */
	left: 5.9vw;
	top: 6.5vw;
	/* z-index: 999; */
	background-color: #fff;
}
.ne-one {
	width: 100%;
	height: 26%;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
}
.lineOne {
	width: 50%;
	height: 100%;
	border-top: none;
	border-right: 2px solid #000;
	border-bottom: none;
	border-left: none;
	writing-mode: vertical-rl;
	/* 可选:控制文字方向(确保文字正立) */
	text-orientation: upright;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	line-height: 18px; /* 调整字间距 */
}
.lineTwo {
	width: 50%;
	height: 100%;
	writing-mode: vertical-rl;
	/* 可选:控制文字方向(确保文字正立) */
	text-orientation: upright;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	line-height: 28px; /* 调整字间距 */
}
</style>