bodyCenterLeft.vue 3.07 KB
<template>
	<div class="dv-content-body-center-list-left">
		<dv-border-box-12 :dur="35">
			<div style="width: 100%;">
				<span class="div-span-title">库位使用情况</span>
			</div>

			<!-- 6个数据:一行2个,共3排 → 标签+数值 左右排列 -->
			<div class="data-grid-container">
				<div class="data-item" v-for="(item, index) in showData" :key="index">
					<div class="item-label">{{ item.label }}</div>
					<div class="item-value">{{ item.value }}</div>
				</div>
			</div>
		</dv-border-box-12>
	</div>
</template>

<script>
export default {
	data() {
		return {
			baseUrlOff: 'http://172.16.43.82:6002/api/BulletinBoard/Mes/V1/ReadData1',
			baseUrlOnLine: window.appConfig.baseUrlintTwo,
			sysData: [],
			showData: [
				{ label: '总库位数', value: '0' },
				{ label: '有货库位数', value: '0' },
				{ label: '在库空托盘数', value: '0' },
				{ label: '空闲库位数', value: '0' },
				{ label: '锁定库位数', value: '0' },
				{ label: '库位利用率', value: '0' },
			],
		}
	},
	methods: {
		getData() {
			let opt = {
				urlSuffix: window.baseOnLineOrOff ? this.baseUrlOnLine : this.baseUrlOnLine,
				logTitle: '库位使用情况',
				isUrlALL: true,
				headers: false,
			}
			let callBackFn = (res) => {
				if (!this.ajaxSuccessDataBefore(res, opt.logTitle)) return
				this.updateShowData(res.data.result)
			}
			''.ajax(this, opt, callBackFn)
		},

		updateShowData(data) {
			const item = data
			this.showData = [
				{ label: '总库位数', value: item.totalLocationCount || 0 },
				{ label: '有货库位数', value: item.hasGoodsLocationCount || 0 },
				{ label: '在库空托盘数', value: item.emptyPalletLocationCount || 0 },
				{ label: '空闲库位数', value: item.emptyLocationCount || 0 },
				{ label: '锁定库位数', value: item.lockLocationCount || 0 },
				{ label: '库位利用率', value: item.locationUseRate || 0 },
			]
		},

		ajaxSuccessDataBefore(res, title) {
			if (!res.data || !res.data.result || res.data.result.length === 0) {
				console.log(title + '无数据')
				return false
			}
			return true
		},
	},
	mounted() {
		// this.getData()
	},
}
</script>

<style lang="less" scoped>
.dv-content-body-center-list-left {
	width: 33vw;
	height: 95%;
}

.div-span-title {
	font-size: 1.5vw;
	color: #fff;
	padding: 0.5vw 1vw;
	display: inline-block;
}

/* 布局:一行2个,共3排 */
.data-grid-container {
	width: 95%;
	height: 85%;
	margin-left: 0.8vw;
	display: flex;
	flex-wrap: wrap;
	text-align: center;
	justify-content: space-between;
	// align-content: space-around;
}

/* 单个数据块:标签 + 数值 左右并排 + 内边距充足,不靠边 */
.data-item {
	width: 48%;
	height: 24%;
	background-color: rgba(255, 255, 255, 0.1);
	border-radius: 0.5vw;
	display: flex;
	align-items: center;
	justify-content: flex-start;
	/* 👇 核心:内边距,让文字不靠边 */
	padding: 0 1vw;
	color: #fff;
	box-sizing: border-box;
}

.item-label {
	font-size: 1.3vw;
	opacity: 0.8;
	margin-right: 1vw;
	white-space: nowrap;
}

.item-value {
	font-size: 1.6vw;
	font-weight: bold;
	color: #00eeff;
}
</style>