This commit is contained in:
‘937886381’
2025-12-30 09:04:48 +08:00
parent 80deffbb42
commit 7b3873f9ea
232 changed files with 13127 additions and 17011 deletions

View File

@@ -8,9 +8,9 @@
<div class="center-content">
<!-- 循环 pageRoutes不再硬编码文字 -->
<div class="item" v-for="(page, index) in pageRoutes" :key="index" @click="goToPage(page.path, index)">
<!-- <div class="item" v-for="(page, index) in pageRoutes" :key="index" @click="goToPage(page.path, index)">
<span class="item-text">{{ page.text }}</span>
</div>
</div> -->
</div>
<!-- :class="{ 'no-skew': activeIndex === index }
" -->
@@ -188,7 +188,7 @@ export default {
height: 117px;
width: 100%;
display: flex;
justify-content: space-around;
justify-content: space-between;
background: url('../../../assets/img/topTitle.png') no-repeat;
background-size: cover;
background-position: 0 0;
@@ -339,7 +339,7 @@ export default {
display: flex;
flex-direction: column;
margin-top: 12px;
margin-right: 4px;
margin-right: 16px;
gap: 20px;
}

View File

@@ -26,52 +26,52 @@ import bgBaseTongcheng from '@/assets/images/bgBase/桐城.png';
import bgBaseLuoyang from '@/assets/images/bgBase/洛阳.png';
import bgBaseHefei from '@/assets/images/bgBase/合肥.png';
import bgBaseSuqian from '@/assets/images/bgBase/宿迁.png';
import bgBaseQinhuangdao from '@/assets/images/bgBase/秦皇岛.png';
import bgBaseQinhuangdao from '@/assets/images/bgBase/秦皇岛.png';// 补充:江苏
export default {
name: "BaseSelector",
props: {
factory: {
type: Number,
default: 1, // 默认选中宜兴序号1
validator: (val) => val >= 1 && val <= 8 // 校验序号范围
type: [String, Number],
default: 5, // 新映射中“宜兴”对应序号7
validator: (val) => [5, 2, 7, 3, 8, 9, 10].includes(val) // 校验序号范围匹配新的baseNameToIndexMap
}
},
data() {
return {
activeButton: 0, // 初始化默认选中索引0宜兴)
buttonList: ['宜兴', '漳州', '自贡', '桐城', '洛阳', '合肥', '宿迁', '秦皇岛'],
activeButton: 5, // 初始化默认选中索引2对应buttonList中的“宜兴
buttonList: ['合肥', '桐城', '宜兴', '自贡', '漳州', '洛阳', '秦皇岛', '宿迁'], // 匹配截图顺序
imgMap: {
base: {
宜兴: baseYixing,
漳州: baseZhangzhou,
自贡: baseZigong,
桐城: baseTongcheng,
洛阳: baseLuoyang,
合肥: baseHefei,
宿迁: baseSuqian,
秦皇岛: baseQinhuangdao
桐城: baseTongcheng,
宜兴: baseYixing,
自贡: baseZigong,
漳州: baseZhangzhou,
洛阳: baseLuoyang,
秦皇岛: baseQinhuangdao,
宿迁: baseSuqian
},
bgBase: {
宜兴: bgBaseYixing,
漳州: bgBaseZhangzhou,
自贡: bgBaseZigong,
桐城: bgBaseTongcheng,
洛阳: bgBaseLuoyang,
合肥: bgBaseHefei,
宿迁: bgBaseSuqian,
秦皇岛: bgBaseQinhuangdao
桐城: bgBaseTongcheng,
宜兴: bgBaseYixing,
自贡: bgBaseZigong,
漳州: bgBaseZhangzhou,
洛阳: bgBaseLuoyang,
秦皇岛: bgBaseQinhuangdao,
宿迁: bgBaseSuqian
}
},
baseNameToIndex: {
宜兴: 1,
漳州: 2,
baseNameToIndexMap: { // 新的名称→序号映射
宜兴: 7,
漳州: 8,
自贡: 3,
桐城: 4,
洛阳: 5,
合肥: 6,
宿迁: 7,
秦皇岛: 8
桐城: 2,
洛阳: 9,
合肥: 5,
秦皇岛: 10, // 补充
宿迁: 6 // 补充
}
};
},
@@ -79,20 +79,20 @@ export default {
// 监听父组件传递的factory变化同步本地选中索引
factory: {
handler(newVal) {
// 强制转换为数字,避免非数字值导致错误
const val = Number(newVal);
if (val >= 1 && val <= 8) {
this.activeButton = val - 1; // 序号1→索引0宜兴
} else {
this.activeButton = 0; // 非法值默认选中宜兴
}
// 根据新的baseNameToIndexMap找到对应的基地名称
const targetName = Object.keys(this.baseNameToIndexMap).find(name => this.baseNameToIndexMap[name] === newVal);
// 根据名称找到buttonList中的索引
const targetIndex = this.buttonList.indexOf(targetName);
// 合法索引则更新,否则默认选中宜兴
this.activeButton = targetIndex > -1 ? targetIndex : 2;
console.log('当前选中基地:', this.buttonList[this.activeButton], '序号:', newVal);
},
immediate: true // 初始化立即执行
},
// 监听本地选中索引变化,向父组件发送事件
activeButton(newVal) {
const selectedIndex = newVal + 1; // 索引0→序号1
const selectedName = this.buttonList[newVal];
const selectedIndex = this.baseNameToIndexMap[selectedName] || 5; // 默认返回宜兴的序号7
this.$emit('baseChange', selectedIndex);
}
},
@@ -101,12 +101,12 @@ export default {
this.activeButton = index;
},
getIndexByName(name) {
return this.baseNameToIndex[name] || 1;
return this.baseNameToIndexMap[name] || 5;
}
},
mounted() {
// 修复:初始化时触发事件,传递默认选中的宜兴序号(1
this.$emit('baseChange', 1);
// 初始化时触发事件,传递默认选中的宜兴序号(7
this.$emit('baseChange', 5);
}
};
</script>
@@ -126,7 +126,7 @@ export default {
text-align: center;
cursor: pointer;
white-space: nowrap;
margin-right: -35px;
margin-right: -35px; // 重叠效果,可根据需求调整
transition: all 0.2s ease;
&:hover,

View File

@@ -118,11 +118,11 @@ export default {
}
],
yAxis: {
type: 'value',
// type: 'value',
nameTextStyle: { color: 'rgba(0, 0, 0, 0.45)', fontSize: 14, align: 'left' },
// min: () => 0,
// max: (value) => Math.ceil(value.max),
// scale: true,
scale: true,
axisTick: { show: false },
axisLabel: { color: 'rgba(0, 0, 0, 0.45)', fontSize: 12 },
splitLine: { lineStyle: { color: 'rgba(0, 0, 0, 0.15)' } },

View File

@@ -54,50 +54,37 @@
export default {
name: "Container",
components: {},
props: ["finance",'dateData'],
props: {
finance: {
type: Object,
default: () => ({}) // 明确props默认值为空对象
},
dateData: {
type: Object,
default: () => ({})
}
},
data() {
return {
// 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'
// }
// ]
// 关键修复1初始化itemList为空数组必选否则初始状态下v-for报错且数据无法响应式更新
itemList: []
};
},
watch: {
finance: {
handler(newVal) {
if (newVal) {
// 关键修复2增强数据判断避免空值/无效值触发错误
if (newVal && Object.keys(newVal).length > 0) {
// 转换数据并赋值给itemList响应式更新
this.itemList = this.transformData(newVal);
console.log('finance更新itemList已同步', this.itemList);
} else {
// 当finance为空时重置itemList为空数组
this.itemList = [];
}
},
immediate: true,
deep: true
immediate: true, // 组件挂载时立即执行,初始化数据
deep: true // 深度监听finance对象内部属性变化
}
},
methods: {
@@ -112,13 +99,18 @@ export default {
// 遍历映射关系,转换数据
return Mapping.map(mappingItem => {
// 关键修复3兜底更严谨避免rawData[mappingItem.key]不存在导致报错
const data = rawData[mappingItem.key] || { rate: 0, real: 0, target: 0 };
// 额外兜底避免data中的属性为undefined
const target = data.target || 0;
const real = data.real || 0;
const rate = data.rate || 0;
return {
name: mappingItem.name,
targetValue: data.target,
currentValue: data.real,
progress: Math.round(data.rate), // 将小数率转换为百分比并四舍五入
targetValue: target,
currentValue: real,
progress: Math.round(rate), // 将小数率转换为百分比并四舍五入
route: mappingItem.route
};
});
@@ -128,9 +120,10 @@ export default {
this.$router.push({
path: route,
query: {
dateData: this.dateData
// 关键修复4dateData是对象需序列化后传递否则路由query无法正常接收对象
dateData: JSON.stringify(this.dateData)
}
});
});
}
}
}
@@ -254,7 +247,7 @@ export default {
/* 进度条 - 实际值≥目标值(绿色) */
.bar-exceed {
background:rgba(98, 213, 180, 1) !important;
background: rgba(98, 213, 180, 1) !important;
opacity: 1 !important;
}