239 lines
6.0 KiB
Vue
239 lines
6.0 KiB
Vue
<template>
|
||
<div style="flex: 1">
|
||
<Container :name="title" icon="cockpitItemIcon" size="operatingRevenueBg" topSize="middle">
|
||
<!-- 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" @click="handleDashboardClick('/unitPriceAnalysis/unitPriceAnalysisBase')">
|
||
<div class="title">
|
||
单价·万㎡
|
||
</div>
|
||
<div class="line">
|
||
<operatingSingleBar :detailData="{
|
||
...(relatedTotal.单价 || defaultData),
|
||
flag: getRateFlag((relatedTotal.单价 || defaultData).completeRate, (relatedTotal.单价 || defaultData).real, (relatedTotal.单价 || defaultData).target)
|
||
}" />
|
||
</div>
|
||
</div>
|
||
<div class="dashboard right">
|
||
<div class="title">
|
||
运费·万元
|
||
</div>
|
||
<div class="line">
|
||
<operatingSingleBar :detailData="{
|
||
...(relatedTotal.运费 || defaultData),
|
||
flag: getRateFlag((relatedTotal.运费 || defaultData).completeRate, (relatedTotal.运费 || defaultData).real, (relatedTotal.运费 || defaultData).target)
|
||
}" />
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</Container>
|
||
</div>
|
||
</template>
|
||
<script>
|
||
import Container from './container.vue'
|
||
import operatingSingleBar from './operatingSingleBar.vue'
|
||
|
||
// import * as echarts from 'echarts'
|
||
// import rawItem from './raw-Item.vue'
|
||
|
||
export default {
|
||
name: 'ProductionStatus',
|
||
components: { Container, operatingSingleBar },
|
||
props: {
|
||
relatedTotal: {
|
||
type: Object,
|
||
default: () => ({
|
||
单价: { completeRate: 0, diff: 0, real: 0, target: 0, thb: 0 },
|
||
运费: { completeRate: 0, diff: 0, real: 0, target: 0, thb: 0 },
|
||
})
|
||
},
|
||
dateData: {
|
||
type: Object,
|
||
default: () => ({})
|
||
},
|
||
factory: {
|
||
type: [String, Number],
|
||
default: ''
|
||
},
|
||
title: {
|
||
type: String,
|
||
default: ''
|
||
},
|
||
},
|
||
data() {
|
||
return {
|
||
chart: null,
|
||
// 兜底数据:防止字段缺失时报错
|
||
defaultData: {
|
||
completeRate: 0,
|
||
diff: 0,
|
||
real: 0,
|
||
target: 0,
|
||
thb: 0
|
||
}
|
||
}
|
||
},
|
||
watch: {
|
||
relatedTotal: {
|
||
handler(newValue) {
|
||
this.updateChart()
|
||
},
|
||
immediate: true, // 初始化时立即执行
|
||
deep: true
|
||
}
|
||
},
|
||
mounted() {
|
||
// 初始化图表
|
||
this.$nextTick(() => this.updateChart())
|
||
},
|
||
methods: {
|
||
handleDashboardClick(path) {
|
||
this.$router.push({
|
||
path: path,
|
||
query: {
|
||
factory: this.$route.query.factory ? this.$route.query.factory : this.factory,
|
||
dateData: this.dateData
|
||
}
|
||
})
|
||
},
|
||
/**
|
||
* 判断完成率对应的flag值(<100为0,≥100为1)
|
||
* @param {number} rate 完成率(原始值,如89代表89%)
|
||
* @returns {0|1} flag值
|
||
*/
|
||
getRateFlag(rate, real, target) {
|
||
if (isNaN(rate) || rate === null || rate === undefined) return 0;
|
||
|
||
// 1. 完成率 >= 100 => 达标
|
||
if (rate >= 100) return 1;
|
||
|
||
// 2. 完成率 = 0 且 (目标值=0 或 实际值=目标值=0) => 达标
|
||
if (rate === 0 && target === 0) return 1;
|
||
|
||
// 其他情况 => 未达标
|
||
return 0;
|
||
},
|
||
|
||
/**
|
||
* 图表更新方法:可在这里补充全局的图表刷新逻辑
|
||
* 若子组件内部已监听 chartData 变化,此方法可留空或补充额外逻辑
|
||
*/
|
||
updateChart() {
|
||
}
|
||
}
|
||
}
|
||
</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;
|
||
}
|
||
|
||
.dashboard {
|
||
width: 382px;
|
||
height: 205px;
|
||
background: #F9FCFF;
|
||
padding: 16px 0 0 16px;
|
||
|
||
.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;
|
||
}
|
||
|
||
.number {
|
||
display: flex;
|
||
align-items: center;
|
||
gap: 30px;
|
||
// width: 190px;
|
||
height: 32px;
|
||
font-family: YouSheBiaoTiHei;
|
||
font-size: 32px;
|
||
color: #0B58FF;
|
||
line-height: 32px;
|
||
letter-spacing: 2px;
|
||
text-align: left;
|
||
font-style: normal;
|
||
}
|
||
|
||
.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;
|
||
font-style: normal;
|
||
}
|
||
}
|
||
|
||
// .line {
|
||
// width: 500px;
|
||
// height: 205px;
|
||
// background: #F9FCFF;
|
||
// }
|
||
|
||
// .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;
|
||
// }
|
||
// }
|
||
</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> -->
|