修改
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<div class="coreItem">
|
||||
<div class="item" @click="handleRoute(item.route)" v-for="(item, index) in itemList" :key="index">
|
||||
<div class="unit">{{ item.unit }}</div>
|
||||
<div class="name">{{ item.name }}</div>
|
||||
<div class="item-content">
|
||||
<div class="content-wrapper">
|
||||
<div class="left">
|
||||
@@ -54,45 +54,83 @@
|
||||
export default {
|
||||
name: "Container",
|
||||
components: {},
|
||||
props: ["name", "size", "icon"],
|
||||
props: ["finance",'dateData'],
|
||||
data() {
|
||||
return {
|
||||
itemList: [
|
||||
{
|
||||
unit: "营业收入·万元",
|
||||
targetValue: 16,
|
||||
currentValue: 17.2, // 大于目标值(绿色)
|
||||
progress: 107.5,
|
||||
route: 'operatingRevenue'
|
||||
},
|
||||
{
|
||||
unit: "经营性利润·万元",
|
||||
targetValue: 16,
|
||||
currentValue: 16, // 等于目标值(绿色)
|
||||
progress: 100,
|
||||
route: 'profitAnalysis'
|
||||
},
|
||||
{
|
||||
unit: "利润总额·万元",
|
||||
targetValue: 16,
|
||||
currentValue: 14.8, // 小于目标值(黄色)
|
||||
progress: 92.5,
|
||||
route: 'profitAnalysis'
|
||||
},
|
||||
{
|
||||
unit: "毛利率·%",
|
||||
targetValue: 16,
|
||||
currentValue: 15.5, // 小于目标值(黄色)
|
||||
progress: 96.875,
|
||||
route: 'profitAnalysis'
|
||||
}
|
||||
]
|
||||
// itemList: [
|
||||
// {
|
||||
// name: "营业收入·万元",
|
||||
// targetValue: 16,
|
||||
// currentValue: 17.2, // 大于目标值(绿色)
|
||||
// progress: 107.5,
|
||||
// route: 'operatingRevenue'
|
||||
// },
|
||||
// {
|
||||
// name: "经营性利润·万元",
|
||||
// targetValue: 16,
|
||||
// currentValue: 16, // 等于目标值(绿色)
|
||||
// progress: 100,
|
||||
// route: 'profitAnalysis'
|
||||
// },
|
||||
// {
|
||||
// name: "利润总额·万元",
|
||||
// targetValue: 16,
|
||||
// currentValue: 14.8, // 小于目标值(黄色)
|
||||
// progress: 92.5,
|
||||
// route: 'profitAnalysis'
|
||||
// },
|
||||
// {
|
||||
// name: "毛利率·%",
|
||||
// targetValue: 16,
|
||||
// currentValue: 15.5, // 小于目标值(黄色)
|
||||
// progress: 96.875,
|
||||
// route: 'profitAnalysis'
|
||||
// }
|
||||
// ]
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
finance: {
|
||||
handler(newVal) {
|
||||
if (newVal) {
|
||||
this.itemList = this.transformData(newVal);
|
||||
}
|
||||
},
|
||||
immediate: true,
|
||||
deep: true
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
transformData(rawData) {
|
||||
// 定义指标映射关系,包括名称、对应的数据键和路由
|
||||
const Mapping = [
|
||||
{ key: 'operatingRevenue', name: '营业收入·万元', route: 'operatingRevenue' },
|
||||
{ key: 'operatingIncome', name: '经营性利润·万元', route: 'profitAnalysis' },
|
||||
{ key: 'totalProfit', name: '利润总额·万元', route: 'profitAnalysis' },
|
||||
{ key: 'grossMargin', name: '毛利率·%', route: 'profitAnalysis' }
|
||||
];
|
||||
|
||||
// 遍历映射关系,转换数据
|
||||
return Mapping.map(mappingItem => {
|
||||
const data = rawData[mappingItem.key] || { rate: 0, real: 0, target: 0 };
|
||||
|
||||
return {
|
||||
name: mappingItem.name,
|
||||
targetValue: data.target,
|
||||
currentValue: data.real,
|
||||
progress: Math.round(data.rate), // 将小数率转换为百分比并四舍五入
|
||||
route: mappingItem.route
|
||||
};
|
||||
});
|
||||
},
|
||||
handleRoute(route) {
|
||||
if (route) {
|
||||
this.$router.push({ path: route });
|
||||
this.$router.push({
|
||||
path: route,
|
||||
query: {
|
||||
dateData: this.dateData
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -120,7 +158,7 @@ export default {
|
||||
transform: translateY(-2px);
|
||||
}
|
||||
|
||||
.unit {
|
||||
.name {
|
||||
height: 18px;
|
||||
font-family: PingFangSC, PingFang SC;
|
||||
font-weight: 400;
|
||||
|
||||
Reference in New Issue
Block a user