bodyCenterRight.vue 3.5 KB
<template>
	<div class="dv-content-body-center-list-right">
		<div class="div-span-title" style="margin-bottom: 2vh">AGV充电状态</div>
			<div
			style="display: flex;
        height: 90%;
    width: 98%;
    flex-wrap: wrap;
    justify-content: center;
    margin-left: 3vw;
   "
		>
			<div class="div-span-title-bottom" v-for="(item, index) in agvDataList" :key="index">
				<div class="agvFont">{{ item.agvNumber }}</div>
				<div class="BottomStyleTop">
					<!-- <div class="BottomStyle">速度:{{ item.speed / 100 }}m/s</div> -->
					<div class="dianchiCss">
						<div class="agvFont" style="width: 30%;">电量:</div>
						<div class="agvFont" style="width: 50%;height: 60%;" :id="createChartId(index)"></div>
						<div class="agvFont" style="width: 6%;">{{ item.battery }}%</div>
					</div>
				</div>
				<div class="agvFont">
					状态:<a :style="getStatus(item.status)">{{ item.status }}</a>
				</div>
			</div>
		</div>
	</div>
</template>

<script>
export default {
	data() {
		return {
			agvDataList: [],
			sysData: {},
			baseUrlOff: 'http://127.0.0.1:6001/api/BulletinBoard/Mes/V1/ReadData1',
			baseUrlOnLine: window.appConfig.baseUrlint,
		}
	},
	methods: {
		getData(data) {
			let myChart = this.$echarts.init(document.getElementById('mind'))
			overviewOfLibraryInformation_bodyCenterRight.series.data = []
			overviewOfLibraryInformation_bodyCenterRight.series.data = data

			myChart.clear()
			myChart.setOption(overviewOfLibraryInformation_bodyCenterRight)
		},
		createChartId(index) {
			return 'main_' + index
		},
		getStatus(s) {
			if (s == '在线' || s == '充电中') {
				return {
					color: 'green',
					textDecoration: 'none',
				}
			} else if (s == '离线') {
				return {
					color: 'gray',
					textDecoration: 'none',
				}
			} else if (s == '故障') {
				return {
					color: 'red',
					textDecoration: 'none',
				}
			} else {
				return {
					color: 'gray',
					textDecoration: 'none',
				}
			}
		},
		agv() {
			let opt = {
				urlSuffix: window.baseOnLineOrOff ? this.baseUrlOnLine : this.baseUrlOff,
				logTitle: 'agv',
				isUrlALL: true,
				headers: window.baseOnLineOrOff,
               isHanderAjaxSuccessActionLoad: true,
			}
			let callBackFn = (res) => {
				if (!this.ajaxSuccessDataBefore(res, opt.logTitle)) return
				this.agvDataList = this.sysData
				setTimeout(() => {
					this.getDianliang()
				}, 300)
			}
			''.ajax(this, opt, callBackFn)
		},
		getDianliang() {
			for (let i = 0; i < this.agvDataList.length; i++) {
				let myChart = this.$echarts.init(document.getElementById('main_' + i))
				dianLiangOne.series[1].data = [this.agvDataList[i].battery]
				myChart.clear()
				myChart.setOption(dianLiangOne)
				window.onresize = myChart.resize
			}
		},
		ajaxSuccessDataBefore(res, title) {
			if (res.data.data == null || res.data.data.length == 0) {
				this.sysData = []
				''.Log(title + '无数据', 'getData')
				return false
			}
			return true
		},
	},
	mounted() {
		this.agv()
		setInterval(() => {
			this.agv()
		}, 10000)
	},
}
</script>
<style lang="less" scoped>
.dv-content-body-center-list-right {
	width: 49%;
	height: 95%;
	border: 1.5px solid hsl(208.57deg 51.22% 40.2%);
}
.div-span-title-bottom {
	// display: flex;
	width: 33%;
	height: 20%;
}
.agvFont {
	font-size: 1.3vw;
	color: #fff;
	display: contents;
}
.BottomStyleTop {
	height: 1%;
	display: flex;
	flex-direction: column;
	justify-content: space-between;
}

.dianchiCss {
	display: flex;
	font-size: 13px;
	color: aliceblue;
	// margin: 20px 0 0 20px;
	align-items: center;
}
</style>