修改
This commit is contained in:
@@ -1,48 +1,54 @@
|
||||
<template>
|
||||
<div style="flex: 1">
|
||||
<Container :name="title" icon="cockpitItemIcon" size="opLargeBg" topSize="large">
|
||||
<!-- 1. 移除 .kpi-content 的固定高度,改为自适应 -->
|
||||
<Container :isShowTab="true" :name="title" icon="cockpitItemIcon" size="opLargeBg" topSize="large"
|
||||
@tabChange="handleChange">
|
||||
<div class="kpi-content" style="padding: 14px 16px; display: flex; width: 100%;">
|
||||
<!-- 新增:topItem 专属包裹容器,统一控制样式和布局 -->
|
||||
<!-- 横向滚动容器:适配5个成本组件,与第二个组件样式统一 -->
|
||||
<div class="topItem-container" style="display: flex; gap: 8px;">
|
||||
<div class="dashboard left" @click="handleDashboardClick('原料成本')">
|
||||
<!-- 1. 原料成本组件:传递对应筛选数据 -->
|
||||
<div class="dashboard left" @click="handleDashboardClick('原料成本','fuelCostAnalysis/fuelCostAnalysis')">
|
||||
<div class="title">
|
||||
原料成本·单位/万元
|
||||
</div>
|
||||
<div class="line">
|
||||
<operatingSingleBar></operatingSingleBar>
|
||||
<operatingSingleBar :detailData="rawMaterialCostData"></operatingSingleBar>
|
||||
</div>
|
||||
</div>
|
||||
<div class="dashboard right" @click="handleDashboardClick('燃料成本')">
|
||||
<!-- 2. 燃料成本组件:传递对应筛选数据 -->
|
||||
<div class="dashboard right" @click="handleDashboardClick('燃料成本','combustible/combustible')">
|
||||
<div class="title">
|
||||
燃料成本·单位/万元
|
||||
</div>
|
||||
<div class="line">
|
||||
<operatingSingleBar></operatingSingleBar>
|
||||
<operatingSingleBar :detailData="fuelCostData"></operatingSingleBar>
|
||||
</div>
|
||||
</div>
|
||||
<div class="dashboard right" @click="handleDashboardClick('电成本')">
|
||||
<!-- 3. 电成本组件:传递对应筛选数据 -->
|
||||
<div class="dashboard right" @click="handleDashboardClick('电成本','osElectricityCostAnalysis')">
|
||||
<div class="title">
|
||||
电成本·单位/万元
|
||||
</div>
|
||||
<div class="line">
|
||||
<operatingSingleBar></operatingSingleBar>
|
||||
<operatingSingleBar :detailData="electricCostData"></operatingSingleBar>
|
||||
</div>
|
||||
</div>
|
||||
<div class="dashboard right" @click="handleDashboardClick('人工成本')">
|
||||
<!-- 4. 人工成本组件:传递对应筛选数据 -->
|
||||
<div class="dashboard right" @click="handleDashboardClick('人工成本','originalSheetLabor')">
|
||||
<div class="title">
|
||||
人工成本·单位/万元
|
||||
</div>
|
||||
<div class="line">
|
||||
<operatingSingleBar></operatingSingleBar>
|
||||
<operatingSingleBar :detailData="laborCostData"></operatingSingleBar>
|
||||
</div>
|
||||
</div>
|
||||
<div class="dashboard right" @click="handleDashboardClick('制造成本')">
|
||||
<!-- 5. 制造成本组件:传递对应筛选数据 -->
|
||||
<div class="dashboard right"
|
||||
@click="handleDashboardClick('制造成本','mfgOverheadCostAnalysis/mfgOverheadCostAnalysis')">
|
||||
<div class="title">
|
||||
制造成本·单位/万元
|
||||
</div>
|
||||
<div class="line">
|
||||
<operatingSingleBar></operatingSingleBar>
|
||||
<operatingSingleBar :detailData="manufacturingCostData"></operatingSingleBar>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -50,120 +56,153 @@
|
||||
</Container>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import Container from '../components/container.vue'
|
||||
import operatingSingleBar from './operatingSingleBar.vue'
|
||||
|
||||
// import * as echarts from 'echarts'
|
||||
// import rawItem from './raw-Item.vue'
|
||||
|
||||
export default {
|
||||
name: 'ProductionStatus',
|
||||
name: 'ProductionStatus', // 保持组件名一致(如需区分可重命名为CostProductionStatus)
|
||||
components: { Container, operatingSingleBar },
|
||||
// mixins: [resize],
|
||||
props: {
|
||||
itemData: { // 接收父组件传递的设备数据数组
|
||||
type: Array,
|
||||
default: () => [] // 默认空数组,避免报错
|
||||
// 参考第二个组件,改为接收 成本相关数据(支持月度/累计,与第二个组件格式统一)
|
||||
relatedData: {
|
||||
type: Object,
|
||||
default: () => ({
|
||||
relatedMon: [], // 成本月度数据(数组格式,存储各成本项)
|
||||
relatedTotal: [] // 成本累计数据(数组格式,存储各成本项)
|
||||
})
|
||||
},
|
||||
title: { // 接收父组件传递的设备数据数组
|
||||
title: {
|
||||
type: String,
|
||||
default: () => '' // 默认空数组,避免报错
|
||||
default: ''
|
||||
},
|
||||
month: { // 接收父组件传递的设备数据数组
|
||||
month: {
|
||||
type: String,
|
||||
default: () => '' // 默认空数组,避免报错
|
||||
default: ''
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
chart: null,
|
||||
|
||||
// 核心:当前激活的成本数据集(默认月度数据,与第二个组件逻辑一致)
|
||||
activeData: this.relatedData.relatedMon || [],
|
||||
activeMaterial: '' // 选中的成本名称状态
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
// 1. 原料成本数据:从激活数据集中筛选,与第二个组件筛选逻辑一致
|
||||
rawMaterialCostData() {
|
||||
return this.activeData.find(item => item.name === "原料成本") || {
|
||||
targetValue: 0,
|
||||
value: 0,
|
||||
completed: 0,
|
||||
diffValue: 0
|
||||
};
|
||||
},
|
||||
// 2. 燃料成本数据:精准筛选
|
||||
fuelCostData() {
|
||||
return this.activeData.find(item => item.name === "燃料成本") || {
|
||||
targetValue: 0,
|
||||
value: 0,
|
||||
completed: 0,
|
||||
diffValue: 0
|
||||
};
|
||||
},
|
||||
// 3. 电成本数据:精准筛选
|
||||
electricCostData() {
|
||||
return this.activeData.find(item => item.name === "电成本") || {
|
||||
targetValue: 0,
|
||||
value: 0,
|
||||
completed: 0,
|
||||
diffValue: 0
|
||||
};
|
||||
},
|
||||
// 4. 人工成本数据:精准筛选
|
||||
laborCostData() {
|
||||
return this.activeData.find(item => item.name === "人工成本") || {
|
||||
targetValue: 0,
|
||||
value: 0,
|
||||
completed: 0,
|
||||
diffValue: 0
|
||||
};
|
||||
},
|
||||
// 5. 制造成本数据:精准筛选
|
||||
manufacturingCostData() {
|
||||
return this.activeData.find(item => item.name === "制造成本") || {
|
||||
targetValue: 0,
|
||||
value: 0,
|
||||
completed: 0,
|
||||
diffValue: 0
|
||||
};
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
itemData: {
|
||||
handler(newValue, oldValue) {
|
||||
// this.updateChart()
|
||||
// 监听父组件传递的itemData变化,同步更新激活数据集(与第二个组件逻辑一致)
|
||||
relatedData: {
|
||||
handler(newVal) {
|
||||
this.activeData = newVal.relatedMon || [];
|
||||
},
|
||||
deep: true // 若对象内属性变化需触发,需加 deep: true
|
||||
immediate: true,
|
||||
deep: true
|
||||
}
|
||||
},
|
||||
// computed: {
|
||||
// // 处理排序:包含“总成本”的项放前面,其余项按原顺序排列
|
||||
// sortedItemData() {
|
||||
// // 过滤出包含“总成本”的项(不区分大小写)
|
||||
// const totalCostItems = this.itemData.filter(item =>
|
||||
// item.name && item.name.includes('总成本')
|
||||
// );
|
||||
// // 过滤出不包含“总成本”的项
|
||||
// const otherItems = this.itemData.filter(item =>
|
||||
// !item.name || !item.name.includes('总成本')
|
||||
// );
|
||||
// // 合并:总成本项在前,其他项在后
|
||||
// return [...totalCostItems, ...otherItems];
|
||||
// }
|
||||
// },
|
||||
mounted() {
|
||||
// 初始化图表(若需展示图表,需在模板中添加对应 DOM)
|
||||
// this.$nextTick(() => this.updateChart())
|
||||
console.log('成本组件挂载时的激活数据:', this.activeData);
|
||||
},
|
||||
methods: {
|
||||
handleDashboardClick(material) {
|
||||
// 1. 记录选中状态(可选)
|
||||
handleChange(value) {
|
||||
console.log('Tab 切换值:', value);
|
||||
// 根据 Tab 值更新当前激活的数据集
|
||||
if (value === 'month') {
|
||||
// 切换为月度数据
|
||||
this.activeData = this.relatedData.relatedMon || [];
|
||||
} else {
|
||||
// 切换为累计数据(非 month 均视为累计,可根据实际需求调整判断条件)
|
||||
this.activeData = this.relatedData.relatedTotal || [];
|
||||
}
|
||||
console.log('当前激活数据集:', this.activeData);
|
||||
},
|
||||
// 成本项点击事件:保留跳转功能,优化参数传递
|
||||
handleDashboardClick(material,path) {
|
||||
// 1. 记录选中状态
|
||||
this.activeMaterial = material;
|
||||
|
||||
// 2. 基础逻辑:打印物料名称(可替换为业务逻辑)
|
||||
console.log(`点击了【${material}】,月份:${this.month}`, '物料数据:', this.itemData);
|
||||
console.log(`点击了【${material}】,月份:${this.month}`, '成本数据:', this.activeData);
|
||||
|
||||
// 2. 优化路由跳转:month放入query中(修复原代码参数错误)
|
||||
this.$router.push({
|
||||
path: 'fuelCostAnalysis/fuelCostAnalysis',
|
||||
month: this.month,
|
||||
path: path,
|
||||
query: {
|
||||
name: material
|
||||
name: material,
|
||||
month: this.month
|
||||
}
|
||||
})
|
||||
// 3. 扩展逻辑示例:
|
||||
// - 触发父组件事件(如需向父组件传递数据)
|
||||
});
|
||||
|
||||
// 3. 向父组件传递事件(携带当前成本项的详细数据)
|
||||
this.$emit('dashboard-click', {
|
||||
material,
|
||||
month: this.month,
|
||||
// data: this.itemData.find(item => item.name === material) || {}
|
||||
data: this.activeData.find(item => item.name === material) || {}
|
||||
});
|
||||
|
||||
// - 跳转详情页(如需路由跳转)
|
||||
// this.$router.push({
|
||||
// path: '/material-detail',
|
||||
// query: { name: material, month: this.month }
|
||||
// });
|
||||
|
||||
// - 打开弹窗/加载详情数据等
|
||||
// this.openMaterialDetail(material);
|
||||
},
|
||||
}
|
||||
}
|
||||
</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;
|
||||
}
|
||||
|
||||
@@ -172,26 +211,23 @@ export default {
|
||||
height: 205px;
|
||||
background: #F9FCFF;
|
||||
padding: 16px 0 0 16px;
|
||||
flex-shrink: 0; // 固定宽度,不被挤压(与第二个组件一致)
|
||||
|
||||
.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;
|
||||
margin-bottom: 16px; // 与第二个组件间距一致
|
||||
}
|
||||
|
||||
.number {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 30px;
|
||||
// width: 190px;
|
||||
height: 32px;
|
||||
font-family: YouSheBiaoTiHei;
|
||||
font-size: 32px;
|
||||
@@ -199,7 +235,6 @@ export default {
|
||||
line-height: 32px;
|
||||
letter-spacing: 2px;
|
||||
text-align: left;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
.mom {
|
||||
@@ -212,43 +247,21 @@ export default {
|
||||
line-height: 18px;
|
||||
letter-spacing: 1px;
|
||||
text-align: left;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
// .line {
|
||||
// width: 280px; // 适配310px宽度,避免图表溢出
|
||||
// height: 150px; // 与第二个组件图表高度一致
|
||||
// }
|
||||
}
|
||||
|
||||
// .line {
|
||||
// width: 500px;
|
||||
// height: 205px;
|
||||
// background: #F9FCFF;
|
||||
// }
|
||||
/* 隐藏横向滚动条,与第二个组件样式统一 */
|
||||
.topItem-container::-webkit-scrollbar {
|
||||
display: none;
|
||||
}
|
||||
|
||||
// .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;
|
||||
// }
|
||||
// }
|
||||
.topItem-container {
|
||||
scrollbar-width: none;
|
||||
-ms-overflow-style: none;
|
||||
}
|
||||
</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> -->
|
||||
|
||||
Reference in New Issue
Block a user