新增页面

This commit is contained in:
‘937886381’
2025-12-25 16:48:17 +08:00
parent 2d200dd1a6
commit 80deffbb42
406 changed files with 108362 additions and 189 deletions

View File

@@ -0,0 +1,184 @@
<template>
<div style="flex: 1">
<Container :name="title" icon="cockpitItemIcon" size="operatingRevenueBg" topSize="middle">
<div class="kpi-content" style="padding: 14px 16px; display: flex; width: 100%;">
<div class="topItem-container" style="display: flex; gap: 8px; width: 100%;">
<!-- 累计指标1 -->
<div class="dashboard left">
<div class="title">
收入·单位/万元
</div>
<div class="chart-wrap">
<operatingSingleBar :detailData="ytdIncomeData"></operatingSingleBar>
</div>
</div>
<!-- 累计指标2 -->
<div class="dashboard right">
<div class="title">
全成本·单位/万元
</div>
<div class="chart-wrap">
<operatingSingleBar :detailData="ytdCostData"></operatingSingleBar>
</div>
</div>
</div>
</div>
</Container>
</div>
</template>
<script>
import Container from './container.vue'
import operatingSingleBar from './operatingSingleBar.vue'
export default {
name: 'yearRelatedMetrics',
components: { Container, operatingSingleBar },
props: {
monthAnalysis: {
type: Array,
// 正确写法:默认值通过 factory 函数返回(才能调用 default()
default: () => [
{ title: "累计收入", budget: 0, real: 0, rate: 0, diff: 0 },
{ title: "累计全成本", budget: 0, real: 0, rate: 0, diff: 0 }
]
},
title: {
type: String,
default: ''
}
},
data() {
return {
ytdIncomeData: { title: "累计收入", budget: 0, real: 0, rate: 0, diff: 0, flag: 0 },
ytdCostData: { title: "累计全成本", budget: 0, real: 0, rate: 0, diff: 0, flag: 0 }
}
},
watch: {
monthAnalysis: {
handler(newVal) {
this.updateChart(newVal)
},
deep: true,
immediate: true
}
},
mounted() {
this.updateChart(this.monthAnalysis)
},
methods: {
getRateFlag(rate) {
if (isNaN(rate) || rate === null || rate === undefined) return 0;
return rate >= 100 ? 1 : 0;
},
updateChart(data) {
// 修复核心:正确获取默认值(调用 factory 函数)
// 错误写法this.$props.ytdAnalysis.default()
// 正确写法this.ytdAnalysis 默认值已通过 factory 函数定义,直接兜底
const validData = Array.isArray(data) && data.length >= 2
? data
: this.$props.monthAnalysis; // 直接取 props 默认值
// 提取累计收入第0项、累计全成本第1项数据
const incomeItem = validData[0] || { title: "累计收入", budget: 0, real: 0, rate: 0, diff: 0 };
const costItem = validData[1] || { title: "累计全成本", budget: 0, real: 0, rate: 0, diff: 0 };
// 整合flag字段
this.ytdIncomeData = {
...incomeItem,
flag: this.getRateFlag(incomeItem.rate)
};
this.ytdCostData = {
...costItem,
flag: this.getRateFlag(costItem.rate)
};
console.log('累计收入数据:', this.ytdIncomeData);
console.log('累计全成本数据:', this.ytdCostData);
}
}
}
</script>
<style lang='scss' scoped>
// 样式与之前一致,无需修改
.scroll-container {
max-height: 210px;
overflow-y: auto;
overflow-x: hidden;
padding: 10px 0;
&::-webkit-scrollbar {
display: none;
}
scrollbar-width: none;
-ms-overflow-style: none;
}
.topItem-container {
display: flex;
justify-content: space-between;
}
.dashboard {
flex: 1;
min-width: 300px;
height: 205px;
background: #F9FCFF;
padding: 16px 16px 0;
margin: 0 4px;
.title {
height: 18px;
font-family: PingFangSC, PingFang SC;
font-weight: 400;
font-size: 18px;
color: #000000;
line-height: 18px;
letter-spacing: 2px;
text-align: left;
margin-bottom: 12px;
}
.chart-wrap {
width: 100%;
height: calc(100% - 30px);
}
.number {
display: flex;
align-items: center;
gap: 30px;
height: 32px;
font-family: YouSheBiaoTiHei;
font-size: 32px;
color: #0B58FF;
line-height: 32px;
letter-spacing: 2px;
text-align: left;
}
.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;
}
}
.dashboard.left {
margin-left: 0;
}
.dashboard.right {
margin-right: 0;
}
</style>