282 lines
7.6 KiB
Vue
282 lines
7.6 KiB
Vue
<template>
|
||
<div style="flex: 1">
|
||
<Container name="采购重点指标" nameTwo="存货重点指标" icon="cockpitItemIcon" size="bottomBasic">
|
||
<!-- 1. 移除 .kpi-content 的固定高度,改为自适应 -->
|
||
<div class="bottom-left-content" style="display: flex;gap: 9px;padding: 14px 16px;">
|
||
<coreBottomLeftItem :dateData="dateData" :purchase="purchase">
|
||
</coreBottomLeftItem>
|
||
<div class="content-right" style="background: #F9FCFF;padding: 15px 12px;">
|
||
<base-table style="height: 180px;width: 260px;" :page="1" :limit="10" :show-index="true" :beilv="1"
|
||
:tableConfig="tableProps" :table-data="maintenanceTasks" />
|
||
</div>
|
||
</div>
|
||
</Container>
|
||
</div>
|
||
</template>
|
||
<script>
|
||
import Container from './bottomLeftContainer.vue'
|
||
// import * as echarts from 'echarts'
|
||
import coreBottomLeftItem from './core-bottom-leftItem.vue'
|
||
import baseTable from './baseTable.vue'
|
||
|
||
|
||
export default {
|
||
name: 'ProductionStatus',
|
||
components: { Container, coreBottomLeftItem, baseTable },
|
||
// mixins: [resize],
|
||
props: {
|
||
purchase: { // 接收父组件传递的设备数据数组
|
||
type: Object,
|
||
default: () => {} // 默认空数组,避免报错
|
||
},
|
||
dateData: { // 接收父组件传递的设备数据数组
|
||
type: Object,
|
||
default: () => { } // 默认空数组,避免报错
|
||
},
|
||
inventory: { // 恢复生产概览数据(原代码注释了,需根据实际需求保留)
|
||
type: Object,
|
||
default: () => ({})
|
||
}
|
||
},
|
||
data() {
|
||
return {
|
||
maintenanceTasks: [
|
||
{ id: 1, name: '纯碱', number: '1313,252', },
|
||
{ id: 2, name: '硅砂', number: '14,252', },
|
||
{ id: 2, name: '白云石', number: '23,252', },
|
||
{ id: 2, name: '石灰石', number: '34,421', },
|
||
{ id: 2, name: '氧化铝', number: '1,251.34', },
|
||
{ id: 2, name: '氢氧化铝', number: '14,252', },
|
||
|
||
// { id: 2, eqName: '螺杆挤出', taskName: '例行维护', },
|
||
// { id: 2, eqName: '螺杆挤出', taskName: '例行维护', },
|
||
// { id: 2, eqName: '螺杆挤出', taskName: '例行维护', },
|
||
// { id: 2, eqName: '螺杆挤出', taskName: '例行维护', },
|
||
// { id: 2, eqName: '螺杆挤出', taskName: '例行维护', },
|
||
|
||
],
|
||
tableProps: [
|
||
// { prop: 'id', label: '序号', width: 50, align: 'center' },
|
||
{ prop: 'name', label: '物料', align: 'left' },
|
||
{ prop: 'number', label: '库存/吨', align: 'left' },
|
||
]
|
||
}
|
||
},
|
||
watch: {
|
||
inventory: {
|
||
handler(newInventoryData) {
|
||
// 当 inventory 数据变化时,执行转换函数
|
||
this.maintenanceTasks = this.transformInventoryData(newInventoryData);
|
||
},
|
||
immediate: true, // 组件初始化时立即执行一次
|
||
deep: true // 深度监听对象内部属性的变化
|
||
}
|
||
},
|
||
mounted() {
|
||
// 组件挂载时,如果有初始 inventory 数据,也执行一次转换
|
||
if (this.inventory) {
|
||
this.maintenanceTasks = this.transformInventoryData(this.inventory);
|
||
}
|
||
},
|
||
beforeDestroy() {
|
||
// 销毁图表,避免内存泄漏
|
||
if (this.chart) {
|
||
this.chart.dispose()
|
||
this.chart = null
|
||
}
|
||
},
|
||
methods: {
|
||
/**
|
||
* 核心转换函数:将 inventory 对象转换为 maintenanceTasks 数组
|
||
* @param {Object} inventoryData - 格式如: { "纯碱": 0, "硅砂": 0, ... }
|
||
* @returns {Array} - 格式如: [ { id: 1, name: '纯碱', number: '0' }, ... ]
|
||
*/
|
||
transformInventoryData(inventoryData) {
|
||
// 检查输入是否为有效的非空对象
|
||
if (!inventoryData || typeof inventoryData !== 'object' || Object.keys(inventoryData).length === 0) {
|
||
return []; // 如果无效,返回空数组
|
||
}
|
||
|
||
// 使用 Object.entries() 和 map() 进行转换
|
||
return Object.entries(inventoryData).map(([name, value], index) => {
|
||
return {
|
||
id: index + 1, // id 从 1 开始自增
|
||
name: name, // 物料名称
|
||
number: String(value) // 将数值转换为字符串,以匹配 "number" 字段
|
||
};
|
||
});
|
||
}
|
||
}
|
||
}
|
||
</script>
|
||
|
||
<style lang='scss' scoped>
|
||
/* 3. 核心:滚动容器样式(固定高度+溢出滚动+隐藏滚动条) */
|
||
.scroll-container {
|
||
/* 1. 固定容器高度:根据页面布局调整(示例300px,超出则滚动) */
|
||
max-height: 210px;
|
||
/* 2. 溢出滚动:内容超出高度时显示滚动功能 */
|
||
overflow-y: auto;
|
||
/* 3. 隐藏横向滚动条(防止设备名过长导致横向滚动) */
|
||
overflow-x: hidden;
|
||
/* 4. 内边距:与标题栏和容器边缘对齐 */
|
||
padding: 10px 0;
|
||
|
||
/* 5. 隐藏滚动条(兼容主流浏览器) */
|
||
/* Chrome/Safari */
|
||
&::-webkit-scrollbar {
|
||
display: none;
|
||
}
|
||
|
||
/* Firefox */
|
||
scrollbar-width: none;
|
||
/* IE/Edge */
|
||
-ms-overflow-style: none;
|
||
}
|
||
|
||
/* 设备项样式优化:增加间距,避免拥挤 */
|
||
.proBarInfo {
|
||
display: flex;
|
||
flex-direction: column;
|
||
padding: 8px 27px;
|
||
/* 调整内边距,优化排版 */
|
||
margin-bottom: 10px;
|
||
/* 设备项之间的垂直间距 */
|
||
}
|
||
|
||
/* 原有样式保留,优化细节 */
|
||
.proBarInfoEqInfo {
|
||
display: flex;
|
||
justify-content: space-between;
|
||
align-items: center;
|
||
/* 垂直居中,避免序号/文字错位 */
|
||
}
|
||
|
||
.slot {
|
||
width: 21px;
|
||
height: 23px;
|
||
background: rgba(0, 106, 205, 0.22);
|
||
backdrop-filter: blur(1.5px);
|
||
font-family: PingFangSC, PingFang SC;
|
||
font-weight: 400;
|
||
font-size: 16px;
|
||
color: #68B5FF;
|
||
line-height: 23px;
|
||
/* 垂直居中文字 */
|
||
text-align: center;
|
||
font-style: normal;
|
||
}
|
||
|
||
.eq-name {
|
||
margin-left: 8px;
|
||
/* 增加与序号的间距 */
|
||
font-family: PingFangSC, PingFang SC;
|
||
font-weight: 400;
|
||
font-size: 16px;
|
||
color: #FFFFFF;
|
||
line-height: 18px;
|
||
letter-spacing: 1px;
|
||
text-align: left;
|
||
font-style: normal;
|
||
}
|
||
|
||
.eqStatus {
|
||
font-family: PingFangSC, PingFang SC;
|
||
font-weight: 400;
|
||
font-size: 16px;
|
||
color: #FFFFFF;
|
||
line-height: 18px;
|
||
text-align: right;
|
||
font-style: normal;
|
||
}
|
||
|
||
.splitLine {
|
||
width: 1px;
|
||
height: 14px;
|
||
border: 1px solid #ADADAD;
|
||
margin: 0 8px;
|
||
/* 优化分割线间距 */
|
||
}
|
||
|
||
.yield {
|
||
height: 18px;
|
||
font-family: PingFangSC, PingFang SC;
|
||
font-weight: 400;
|
||
font-size: 16px;
|
||
color: #00FFFF;
|
||
line-height: 18px;
|
||
text-align: right;
|
||
font-style: normal;
|
||
}
|
||
|
||
.proBarInfoEqInfoLeft {
|
||
display: flex;
|
||
align-items: center;
|
||
/* 序号和设备名垂直居中 */
|
||
}
|
||
|
||
.proBarInfoEqInfoRight {
|
||
display: flex;
|
||
align-items: center;
|
||
/* 状态/分割线/百分比垂直居中 */
|
||
}
|
||
|
||
.proBarWrapper {
|
||
position: relative;
|
||
height: 10px;
|
||
margin-top: 6px;
|
||
/* 进度条与上方信息的间距 */
|
||
border-radius: 5px;
|
||
/* 进度条圆角,优化视觉 */
|
||
overflow: hidden;
|
||
}
|
||
|
||
.proBarLine {
|
||
width: 100%;
|
||
height: 100%;
|
||
background: linear-gradient(65deg, rgba(82, 82, 82, 0) 0%, #ACACAC 100%);
|
||
opacity: 0.2;
|
||
}
|
||
|
||
.proBarLineTop {
|
||
position: absolute;
|
||
top: 0;
|
||
left: 0;
|
||
height: 100%;
|
||
background: linear-gradient(65deg, rgba(53, 223, 247, 0) 0%, rgba(54, 220, 246, 0.92) 92%, #36F6E5 100%, #37ACF5 100%);
|
||
border-radius: 5px;
|
||
transition: width 0.3s ease;
|
||
/* 进度变化时添加过渡动画,更流畅 */
|
||
}
|
||
|
||
/* 图表相关样式保留 */
|
||
.chartImgBottom {
|
||
position: absolute;
|
||
bottom: 45px;
|
||
left: 58px;
|
||
}
|
||
|
||
.line {
|
||
display: inline-block;
|
||
position: absolute;
|
||
left: 57px;
|
||
bottom: 42px;
|
||
width: 1px;
|
||
height: 20px;
|
||
background-color: #00E8FF;
|
||
}
|
||
</style>
|
||
|
||
<style>
|
||
/* 全局 tooltip 样式(不使用 scoped,确保生效) */
|
||
.production-status-chart-tooltip {
|
||
background: #0a2b4f77 !important;
|
||
border: none !important;
|
||
backdrop-filter: blur(12px);
|
||
}
|
||
|
||
.production-status-chart-tooltip * {
|
||
color: #fff !important;
|
||
}
|
||
</style>
|