331 lines
8.2 KiB
Vue
331 lines
8.2 KiB
Vue
<template>
|
||
<div style="flex: 1">
|
||
<Container name="溢价产品完成情况" icon="cockpitItemIcon" size="operatingBasic" topSize="middle">
|
||
<!-- 1. 移除 .kpi-content 的固定高度,改为自适应 -->
|
||
<div class="kpi-content" style="padding: 14px 16px 8px 16px; display: flex;flex-direction: column; width: 100%;">
|
||
<!-- 2. .top 保持 flex,无需固定高度,自动跟随子元素拉伸 -->
|
||
<div class="top" style="display: flex; width: 100%;">
|
||
<top-item :itemList="formattedPremiumProductList" />
|
||
</div>
|
||
</div>
|
||
<div class="bottom-content" style="display: flex;flex-direction: column; width: 100%;">
|
||
<div class="content-top">
|
||
<svg-icon style="font-size: 32px; margin-left: 16px" icon-class="cockpitItemIcon" />
|
||
<span style="
|
||
width: 412px;
|
||
height: 32px;
|
||
font-family: PingFangSC, PingFang SC;
|
||
font-weight: 400;
|
||
font-size: 24px;
|
||
color: #000000;
|
||
line-height: 60px;
|
||
letter-spacing: 3px;
|
||
text-align: left;
|
||
font-style: normal;
|
||
">
|
||
各产品类型销量占比
|
||
</span>
|
||
</div>
|
||
<div class="pie" style="display: flex;gap: 8px;margin-top: 68px;padding: 0 16px;">
|
||
<div class="month-pie" style="height: 212px;width: 382px;background: #F9FCFF;">
|
||
<pieChart :pieData="monthPieData" :chartRef=" 'monthChart' " />
|
||
</div>
|
||
<div class="-pie" style="height: 212px;width: 382px;background: #F9FCFF;">
|
||
<pieChartTwo :pieData="yearPieData" :chartRef="'yearChart'" />
|
||
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</Container>
|
||
</div>
|
||
</template>
|
||
<script>
|
||
import Container from './container.vue'
|
||
import pieChart from './pieChart.vue'
|
||
import pieChartTwo from './pieChart.vue'
|
||
|
||
|
||
// import * as echarts from 'echarts'
|
||
import topItem from './operating-item.vue'
|
||
import coreBottomBar from './coreBottomBar.vue'
|
||
|
||
export default {
|
||
name: 'ProductionStatus',
|
||
components: { Container, topItem, coreBottomBar, pieChart, pieChartTwo },
|
||
// mixins: [resize],
|
||
props: {
|
||
premiumProduct: { // 接收父组件传递的设备数据数组
|
||
type: Object,
|
||
default: () => {} // 默认空数组,避免报错
|
||
},
|
||
salesProportion: { // 恢复生产概览数据(原代码注释了,需根据实际需求保留)
|
||
type: Object,
|
||
default: () => ({})
|
||
}
|
||
},
|
||
data() {
|
||
return {
|
||
chart: null,
|
||
monthPieData: {},
|
||
yearPieData:{},
|
||
parentItemList: [
|
||
{
|
||
name: "月度",
|
||
targetValue: 0,
|
||
value: 0,
|
||
proportion: 0,
|
||
route: 'profitAnalysis',
|
||
completed: 1 // 未达预算值,不达标
|
||
},
|
||
{
|
||
name: "年度",
|
||
targetValue: 0,
|
||
value: 0,
|
||
proportion: 0,
|
||
route: 'profitAnalysis',
|
||
completed: 1 // 超出预算值,达标
|
||
}
|
||
]
|
||
}
|
||
},
|
||
watch: {
|
||
salesProportion: {
|
||
handler(newValue, oldValue) {
|
||
console.log('salesProportion',newValue);
|
||
|
||
this.getPieData()
|
||
},
|
||
deep: true // 若对象内属性变化需触发,需加 deep: true
|
||
}
|
||
},
|
||
computed: {
|
||
formattedPremiumProductList() {
|
||
const premiumProductData = this.premiumProduct || {};
|
||
|
||
const nameToKeyMap = {
|
||
"月度": "month",
|
||
"年度": "year"
|
||
};
|
||
|
||
return this.parentItemList.map(item => {
|
||
const key = nameToKeyMap[item.name];
|
||
|
||
if (key && premiumProductData[key]) {
|
||
const periodData = premiumProductData[key];
|
||
|
||
let completed = 0;
|
||
|
||
// 新增:判断三个值是否都为0
|
||
const allZeros = periodData.real === 0 &&
|
||
periodData.target === 0 &&
|
||
periodData.rate === 0;
|
||
|
||
if (allZeros) {
|
||
completed = 1;
|
||
} else if (periodData.rate !== null && periodData.rate !== undefined) {
|
||
completed = periodData.rate >= 1 ? 1 : 0;
|
||
}
|
||
|
||
return {
|
||
...item,
|
||
value: periodData.real,
|
||
targetValue: periodData.target,
|
||
proportion: periodData.rate !== null && periodData.rate !== undefined
|
||
? Math.round(periodData.rate * 100)
|
||
: 0,
|
||
completed: completed,
|
||
};
|
||
}
|
||
|
||
return item;
|
||
});
|
||
}
|
||
},
|
||
mounted() {
|
||
// 初始化图表(若需展示图表,需在模板中添加对应 DOM)
|
||
// this.$nextTick(() => this.updateChart())
|
||
},
|
||
methods: {
|
||
getPieData() {
|
||
this.monthPieData = this.salesProportion ? this.salesProportion.month : {}
|
||
this.yearPieData = this.salesProportion ? this.salesProportion.year : {}
|
||
console.log('this.monthPieData', this.monthPieData, this.yearPieData);
|
||
|
||
}
|
||
}
|
||
}
|
||
</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;
|
||
}
|
||
.bottom-content{
|
||
position: relative;
|
||
// height: 280px;
|
||
padding: 0 0 6px 0;
|
||
.content-top {
|
||
top: 0;
|
||
left: -5px;
|
||
position: absolute;
|
||
height: 60px;
|
||
width: 804px;
|
||
background: url(../../../assets/img/topTileMiddle.png) no-repeat;
|
||
background-size: 100% 100%;
|
||
background-position: 0 0;
|
||
}
|
||
}
|
||
|
||
</style>
|