修改集团及基地图表样式
This commit is contained in:
@@ -2,41 +2,21 @@
|
||||
<div style="flex: 1">
|
||||
<Container :isShowTab="true" :name="title" icon="cockpitItemIcon" size="opLargeBg" topSize="large"
|
||||
@tabChange="handleChange">
|
||||
<!-- 1. 移除 .kpi-content 的固定高度,改为自适应 -->
|
||||
<div class="kpi-content" style="padding: 14px 16px; display: flex; width: 100%;">
|
||||
<!-- 新增:topItem 专属包裹容器,统一控制样式和布局 -->
|
||||
<div class="topItem-container" style="display: flex; gap: 8px;">
|
||||
<div class="dashboard left">
|
||||
<div class="topItem-container" style="display: flex; gap: 8px">
|
||||
<div
|
||||
v-for="item in sortedIndicators"
|
||||
:key="item.key"
|
||||
class="dashboard"
|
||||
>
|
||||
<div class="title">
|
||||
采购单价·元/吨
|
||||
{{ item.name }}·{{ item.unit }}
|
||||
</div>
|
||||
<div class="line">
|
||||
<operatingSingleBar :detailData="unitPriceData"></operatingSingleBar>
|
||||
</div>
|
||||
</div>
|
||||
<div class="dashboard right">
|
||||
<div class="title">
|
||||
产量·吨
|
||||
</div>
|
||||
<div class="line">
|
||||
<operatingSingleBar :detailData="productData"></operatingSingleBar>
|
||||
</div>
|
||||
</div>
|
||||
<div class="dashboard right">
|
||||
<div class="title">
|
||||
单耗·吨
|
||||
</div>
|
||||
<div class="line">
|
||||
<operatingSingleBar :detailData="unitHaoData"></operatingSingleBar>
|
||||
</div>
|
||||
</div>
|
||||
<div class="dashboard right">
|
||||
<div class="title">
|
||||
消耗量·吨
|
||||
</div>
|
||||
<div class="line">
|
||||
<operatingSingleBar :detailData="haoNumData"></operatingSingleBar>
|
||||
<div style='font-size: 16px;text-align: right;padding-right: 5px;'>
|
||||
<span>完成率:<span style='color: #0B58FF;'>{{item.data.proportion}}%</span></span>
|
||||
<span style='display: inline-block;margin-left: 10px;'>差值:<span :style="{color:item.data.completed>0?'#30B590':'#FF9423'}" >{{item.data.diffValue}}</span></span>
|
||||
</div>
|
||||
<operatingSingleBar :detailData="item.data"></operatingSingleBar>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -80,63 +60,50 @@ export default {
|
||||
chart: null,
|
||||
// 核心:当前激活的物料数据集(默认月度数据,与第二个组件逻辑一致)
|
||||
activeData: this.relatedData.relatedMon || [],
|
||||
activeMaterial: '' // 记录选中的物料状态,与第二个组件一致
|
||||
}
|
||||
},
|
||||
// 对齐第二个组件:添加计算属性,精准筛选各物料数据
|
||||
computed: {
|
||||
// 1. 硅砂数据:从激活数据集中筛选,兜底值与第二个组件统一
|
||||
unitPriceData() {
|
||||
console.log('');
|
||||
console.log(this.activeData.find(item => (item.name || '').includes('采购单价')) || {
|
||||
targetValue: 0,
|
||||
value: 0,
|
||||
completed: 0,
|
||||
diffValue: 0
|
||||
},'yyyy')
|
||||
return this.activeData.find(item => (item.name || '').includes('采购单价')) || {
|
||||
targetValue: 0,
|
||||
value: 0,
|
||||
completed: 0,
|
||||
diffValue: 0
|
||||
};
|
||||
indicatorDefs() {
|
||||
return [
|
||||
{ key: 'rawMaterialCost', name: '采购单价', unit: '元/吨'},
|
||||
{ key: 'fuelCost', name: '产量', unit: '吨'},
|
||||
{ key: 'electricityCost', name: '单耗', unit: '吨'},
|
||||
{ key: 'laborCost', name: '消耗量', unit: '吨'}
|
||||
]
|
||||
},
|
||||
indicators() {
|
||||
const fallback = { targetValue: 0, value: 0, completed: 0, diffValue: 0 }
|
||||
const list = (Array.isArray(this.activeData) ? this.activeData : [])
|
||||
|
||||
return this.indicatorDefs.map(def => {
|
||||
const data = list.find(item => item && item.name.includes(def.name)) || fallback
|
||||
return {
|
||||
...def,
|
||||
data,
|
||||
sortValue: Number((data && data.value) ?? 0)
|
||||
}
|
||||
})
|
||||
},
|
||||
sortedIndicators() {
|
||||
const unitOrder = ['元/吨', '吨']
|
||||
const unitRank = (u) => {
|
||||
const idx = unitOrder.indexOf(u)
|
||||
return idx === -1 ? 999 : idx
|
||||
}
|
||||
|
||||
},
|
||||
// 2. 海砂数据:精准筛选
|
||||
productData() {
|
||||
return this.activeData.find(item => (item.name || '').includes('产量')) || {
|
||||
targetValue: 0,
|
||||
value: 0,
|
||||
completed: 0,
|
||||
diffValue: 0
|
||||
};
|
||||
},
|
||||
// 3. 纯碱数据:精准筛选
|
||||
unitHaoData() {
|
||||
return this.activeData.find(item => (item.name || '').includes('单耗')) || {
|
||||
targetValue: 0,
|
||||
value: 0,
|
||||
completed: 0,
|
||||
diffValue: 0
|
||||
};
|
||||
},
|
||||
// 4. 白云石数据:精准筛选
|
||||
haoNumData() {
|
||||
return this.activeData.find(item => (item.name || '').includes('消耗量')) || {
|
||||
targetValue: 0,
|
||||
value: 0,
|
||||
completed: 0,
|
||||
diffValue: 0
|
||||
};
|
||||
},
|
||||
return this.indicators.slice().sort((a, b) => {
|
||||
const ur = unitRank(a.unit) - unitRank(b.unit)
|
||||
if (ur !== 0) return ur
|
||||
const vr = (b.sortValue ?? -Infinity) - (a.sortValue ?? -Infinity)
|
||||
if (vr !== 0) return vr
|
||||
return String(a.key).localeCompare(String(b.key))
|
||||
})
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
// 对齐第二个组件:监听物料数据变化,同步更新激活数据集
|
||||
relatedData: {
|
||||
handler(newVal) {
|
||||
console.log(this.relatedData,'relatedData');
|
||||
|
||||
this.activeData = newVal.relatedMon || [];
|
||||
},
|
||||
immediate: true, // 组件挂载时立即执行
|
||||
|
||||
Reference in New Issue
Block a user