237 lines
5.9 KiB
Vue
237 lines
5.9 KiB
Vue
<template>
|
||
<div style="flex: 1">
|
||
<Container :name="title" icon="cockpitItemIcon" size="operatingRevenueBg" topSize="middle">
|
||
<!-- 1. 移除 .kpi-content 的固定高度,改为自适应 -->
|
||
<div class="kpi-content" style="padding: 14px 16px; display: flex; width: 100%;">
|
||
<!-- 新增:topItem 专属包裹容器,统一控制样式和布局 -->
|
||
<div class="topItem-container" style="display: flex; gap: 8px;">
|
||
<div class="dashboard">
|
||
<div class="title">
|
||
累计完成率
|
||
</div>
|
||
<div class="number">
|
||
<div class="yield">
|
||
{{ formatRate(factoryData?.completeRate) }}%
|
||
</div>
|
||
<div class="mom">
|
||
同比{{ formatRate(factoryData?.thb) }}%
|
||
<img v-if="factoryData?.thb >= 0" class="arrow" src="../../../assets/img/topArrow.png" alt="">
|
||
<img v-else class="arrow" src="../../../assets/img/downArrow.png" alt="">
|
||
</div>
|
||
</div>
|
||
<div class="electricityGauge">
|
||
<electricityGauge id="year" :detailData="factoryData"></electricityGauge>
|
||
</div>
|
||
</div>
|
||
<div class="line" style="padding: 0px;">
|
||
<verticalBarChart :detailData="factoryData">
|
||
</verticalBarChart>
|
||
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</Container>
|
||
</div>
|
||
</template>
|
||
<script>
|
||
import Container from './container.vue'
|
||
import electricityGauge from './electricityGauge.vue'
|
||
import verticalBarChart from './verticalBarChart.vue'
|
||
|
||
// import * as echarts from 'echarts'
|
||
// import rawItem from './raw-Item.vue'
|
||
|
||
export default {
|
||
name: 'ProductionStatus',
|
||
components: { Container, electricityGauge, verticalBarChart },
|
||
props: {
|
||
totalData: {
|
||
type: Object,
|
||
default: () => ({})
|
||
},
|
||
title: {
|
||
type: String,
|
||
default: ''
|
||
},
|
||
month: {
|
||
type: String,
|
||
default: ''
|
||
},
|
||
},
|
||
data() {
|
||
return {
|
||
chart: null,
|
||
}
|
||
},
|
||
computed: {
|
||
/**
|
||
* 自动提取monData中的工厂数据,并新增flag字段
|
||
*/
|
||
factoryData() {
|
||
const factoryKeys = Object.keys(this.totalData);
|
||
if (factoryKeys.length === 0) {
|
||
// 无数据时返回兜底对象(包含flag)
|
||
return {
|
||
completeRate: 0,
|
||
diff: 0,
|
||
real: 0,
|
||
target: 0,
|
||
thb: 0,
|
||
flag: 0 // 兜底flag
|
||
};
|
||
}
|
||
const firstKey = factoryKeys[0];
|
||
const rawData = this.totalData[firstKey];
|
||
// 整合原始数据 + 计算flag
|
||
return {
|
||
completeRate: 0,
|
||
diff: 0,
|
||
real: 0,
|
||
target: 0,
|
||
thb: 0,
|
||
...rawData,
|
||
flag: this.getRateFlag(rawData.completeRate, rawData.real, rawData.target) // 新增flag字段
|
||
};
|
||
}
|
||
},
|
||
methods: {
|
||
/**
|
||
* 格式化百分比数值:处理空值/非数字,兜底为0
|
||
*/
|
||
formatRate(value) {
|
||
if (isNaN(value) || value === null || value === undefined) {
|
||
return 0;
|
||
}
|
||
return value;
|
||
},
|
||
/**
|
||
* 判断完成率对应的flag值(<100为0,≥100为1)
|
||
* @param {number} rate 完成率(原始值,如89代表89%)
|
||
* @returns {0|1} flag值
|
||
*/
|
||
getRateFlag(rate, real, target) {
|
||
if (isNaN(rate) || rate === null || rate === undefined) return 0;
|
||
|
||
// 1. 完成率 >= 100 => 达标
|
||
if (rate >= 100) return 1;
|
||
|
||
// 2. 完成率 = 0 且 (目标值=0 或 实际值=目标值=0) => 达标
|
||
if (rate === 0 && target === 0) return 1;
|
||
|
||
// 其他情况 => 未达标
|
||
return 0;
|
||
},
|
||
}
|
||
}
|
||
</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;
|
||
}
|
||
|
||
.dashboard {
|
||
width: 264px;
|
||
height: 205px;
|
||
background: #F9FCFF;
|
||
padding: 16px 0 0 16px;
|
||
|
||
.title {
|
||
// width: 190px;
|
||
height: 18px;
|
||
font-family: PingFangSC, PingFang SC;
|
||
font-weight: 400;
|
||
font-size: 18px;
|
||
color: #000000;
|
||
line-height: 18px;
|
||
letter-spacing: 1px;
|
||
text-align: left;
|
||
font-style: normal;
|
||
letter-spacing: 2px;
|
||
}
|
||
|
||
.number {
|
||
display: flex;
|
||
align-items: center;
|
||
gap: 30px;
|
||
// width: 190px;
|
||
height: 32px;
|
||
font-family: YouSheBiaoTiHei;
|
||
font-size: 32px;
|
||
color: #0B58FF;
|
||
line-height: 32px;
|
||
letter-spacing: 2px;
|
||
text-align: left;
|
||
font-style: normal;
|
||
}
|
||
|
||
.mom {
|
||
// width: 97px;
|
||
height: 18px;
|
||
font-family: PingFangSC, PingFang SC;
|
||
font-weight: 400;
|
||
font-size: 18px;
|
||
color: #000000;
|
||
line-height: 18px;
|
||
letter-spacing: 1px;
|
||
text-align: left;
|
||
font-style: normal;
|
||
}
|
||
}
|
||
|
||
.line {
|
||
width: 500px;
|
||
height: 205px;
|
||
background: #F9FCFF;
|
||
}
|
||
|
||
// .leftTitle {
|
||
// .item {
|
||
// width: 67px;
|
||
// height: 180px;
|
||
// padding: 37px 23px;
|
||
// background: #F9FCFF;
|
||
// font-family: PingFangSC, PingFang SC;
|
||
// font-weight: 400;
|
||
// font-size: 18px;
|
||
// color: #000000;
|
||
// line-height: 25px;
|
||
// letter-spacing: 1px;
|
||
// // text-align: left;
|
||
// font-style: normal;
|
||
// }
|
||
// }
|
||
</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> -->
|