修改
This commit is contained in:
@@ -49,7 +49,7 @@ export default {
|
||||
// flag 为 0 时使用灰色,为 1 时使用橙色
|
||||
return this.flag === 1
|
||||
? 'rgba(255, 132, 0, 1)'
|
||||
: 'rgba(103, 103, 103, 0.79)';
|
||||
: 'rgba(54, 181, 138, 1)';
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="lineBottom" style="height: 100%; width: 1590px">
|
||||
<costBaseBarChart style="height: 99%; width: 1590px" />
|
||||
<costBaseBarChart :yName="yName" style="height: 99%; width: 1590px" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -51,18 +51,12 @@ import costBaseBarChart from './costBaseBarChart.vue';
|
||||
export default {
|
||||
name: "Container",
|
||||
components: { costBaseBarChart },
|
||||
props: ["name", "size", "icon"],
|
||||
props: ['dateData','yName'],
|
||||
data() {
|
||||
return {
|
||||
isDropdownShow: false,
|
||||
selectedProfit: '原料', // 默认选中"原料"
|
||||
profitOptions: ['原料', '其他选项1', '其他选项2'], // 可根据实际需求修改选项
|
||||
itemList: [
|
||||
{ unit: "单价·元/m²", targetValue: 16, currentValue: 14.5, progress: 90 },
|
||||
{ unit: "净价·元/m²", targetValue: 16, currentValue: 15.2, progress: 85 },
|
||||
{ unit: "销量·万m²", targetValue: 20, currentValue: 16, progress: 80 },
|
||||
{ unit: "双镀面板·万m²", targetValue: 15, currentValue: 13.8, progress: 92 },
|
||||
],
|
||||
};
|
||||
},
|
||||
computed: {},
|
||||
|
||||
@@ -10,6 +10,12 @@ export default {
|
||||
data() {
|
||||
return {};
|
||||
},
|
||||
props: {
|
||||
yName: {
|
||||
type: String,
|
||||
default: () => '元/㎡'
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
this.$nextTick(() => {
|
||||
this.initData();
|
||||
@@ -63,14 +69,14 @@ export default {
|
||||
interval: 0,
|
||||
padding: [5, 0, 0, 0] // 标签向下偏移,避免与柱子底部重叠
|
||||
},
|
||||
data: ['漳州', '桐城', '合肥', '宜兴', '自贡', '洛阳']
|
||||
data: ['6月', '7月', '8月', '9月', '10月', '11月']
|
||||
}
|
||||
],
|
||||
yAxis: [
|
||||
// 左侧Y轴:目标/达标/未达标(数量,单位“片”)
|
||||
{
|
||||
type: 'value',
|
||||
name: '元',
|
||||
name: this.yName,
|
||||
nameTextStyle: {
|
||||
color: 'rgba(0, 0, 0, 0.45)',
|
||||
fontSize: 12,
|
||||
|
||||
@@ -81,8 +81,8 @@ export default {
|
||||
const currentIndex = params[0].dataIndex;
|
||||
// 使用处理后的 safeFlag,避免越界
|
||||
const currentFlag = safeFlag[currentIndex] || 0;
|
||||
const statusText = currentFlag === 0 ? '达标' : '不达标';
|
||||
let html = `${params[0].axisValue}(${statusText})<br/>`;
|
||||
// const statusText = currentFlag === 0 ? '达标' : '不达标';
|
||||
let html = `${params[0].axisValue}<br/>`;
|
||||
params.forEach(item => {
|
||||
const unit = item.seriesName === '完成率' ? '%' : '万元';
|
||||
html += `${item.marker} ${item.seriesName}: ${item.value}${unit}<br/>`;
|
||||
|
||||
@@ -75,16 +75,16 @@ export default {
|
||||
methods: {
|
||||
// 提取核心成本类型(仅保留“原片”“加工”等,去掉“成本”二字)
|
||||
extractCoreCostType(name) {
|
||||
// 匹配“前缀(含分公司/工厂/区域等)+ 核心词 + 任意后缀”,提取中间核心词
|
||||
// 匹配“前缀(含分公司/工厂/区域等)+ 核心词 + 后缀”,提取核心词+后缀
|
||||
// 兼容后缀:成本、费用、支出、损耗等,前缀:XX分公司、XX工厂、XX区域等
|
||||
const match = name.match(/(分公司)\s*([^,。;!?]+?)\s*(成本)/);
|
||||
if (match) {
|
||||
return match[2].trim(); // 提取中间核心词,去除前后空格
|
||||
// 保留核心词+后缀(去除前后空格)
|
||||
return (match[2] + match[3]).trim();
|
||||
}
|
||||
|
||||
// 通用匹配:无明确前缀标识时,提取“最后一个连续汉字后缀”前的内容
|
||||
const generalMatch = name.match(/(.+?)(?=[\u4e00-\u9fa5]{2,}$)/);
|
||||
return generalMatch ? generalMatch[1].trim() : name.trim();
|
||||
// 通用匹配:无明确前缀时,保留完整内容(原逻辑会去除末尾2个以上汉字,此处修改为保留全部)
|
||||
return name.trim();
|
||||
},
|
||||
// 提取地名(成本类型前的核心地区名)
|
||||
extractLocation(name) {
|
||||
@@ -92,11 +92,11 @@ export default {
|
||||
const match = name.match(/(.+?)分公司/);
|
||||
|
||||
if (match) {
|
||||
return match[1].trim() || '未知地区';
|
||||
return match[1].trim() || '';
|
||||
}
|
||||
|
||||
// 兜底(处理不含“分公司”的情况)
|
||||
return '未知地区';
|
||||
return '';
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
<div class="number" :style="{ color: getColorByFlag(item.flag) }">
|
||||
{{ item.value || 0 }}
|
||||
</div>
|
||||
<div class="title">当前值</div>
|
||||
<div class="title">实际值</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 进度条 + 完成率 -->
|
||||
@@ -35,7 +35,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="yield">
|
||||
<span class="progress-percent">完成率</span>
|
||||
<span class="progress-percent" :style="{ color: getColorByFlag(item.flag) }">完成率</span>
|
||||
<!-- 完成率:动态颜色 + 百分比格式 -->
|
||||
<span class="progress-percent progress-value" :style="{ color: getColorByFlag(item.flag) }">
|
||||
{{ getProportionPercent(item.proportion) }}%
|
||||
@@ -138,7 +138,7 @@ export default {
|
||||
getColorByFlag(flag, isProgressBar = false) {
|
||||
const colorMap = {
|
||||
0: {
|
||||
text: 'rgba(103, 103, 103, 0.79)',
|
||||
text: 'rgba(54, 181, 138, 1)',
|
||||
progress: 'rgba(103, 103, 103, 0.5)' // 进度条颜色稍浅
|
||||
},
|
||||
1: {
|
||||
|
||||
@@ -72,17 +72,29 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
// 提取核心成本类型(仅保留“原片”“加工”等,去掉“成本”二字)
|
||||
// extractCoreCostType(name) {
|
||||
// // 匹配“前缀(含分公司/工厂/区域等)+ 核心词 + 任意后缀”,提取中间核心词
|
||||
// // 兼容后缀:成本、费用、支出、损耗等,前缀:XX分公司、XX工厂、XX区域等
|
||||
// const match = name.match(/(分公司)\s*([^,。;!?]+?)\s*(成本)/);
|
||||
// if (match) {
|
||||
// return match[2].trim(); // 提取中间核心词,去除前后空格
|
||||
// }
|
||||
|
||||
// // 通用匹配:无明确前缀标识时,提取“最后一个连续汉字后缀”前的内容
|
||||
// const generalMatch = name.match(/(.+?)(?=[\u4e00-\u9fa5]{2,}$)/);
|
||||
// return generalMatch ? generalMatch[1].trim() : name.trim();
|
||||
// },
|
||||
extractCoreCostType(name) {
|
||||
// 匹配“前缀(含分公司/工厂/区域等)+ 核心词 + 任意后缀”,提取中间核心词
|
||||
// 匹配“前缀(含分公司/工厂/区域等)+ 核心词 + 后缀”,提取核心词+后缀
|
||||
// 兼容后缀:成本、费用、支出、损耗等,前缀:XX分公司、XX工厂、XX区域等
|
||||
const match = name.match(/(分公司)\s*([^,。;!?]+?)\s*(成本)/);
|
||||
if (match) {
|
||||
return match[2].trim(); // 提取中间核心词,去除前后空格
|
||||
// 保留核心词+后缀(去除前后空格)
|
||||
return (match[2] + match[3]).trim();
|
||||
}
|
||||
|
||||
// 通用匹配:无明确前缀标识时,提取“最后一个连续汉字后缀”前的内容
|
||||
const generalMatch = name.match(/(.+?)(?=[\u4e00-\u9fa5]{2,}$)/);
|
||||
return generalMatch ? generalMatch[1].trim() : name.trim();
|
||||
// 通用匹配:无明确前缀时,保留完整内容(原逻辑会去除末尾2个以上汉字,此处修改为保留全部)
|
||||
return name.trim();
|
||||
},
|
||||
// 提取地名(成本类型前的核心地区名)
|
||||
extractLocation(name) {
|
||||
|
||||
@@ -56,7 +56,7 @@ export default {
|
||||
{ prop: 'name', label: '物料名称', align: 'center' },
|
||||
{ prop: 'code', label: '物料编码', align: 'center' },
|
||||
{
|
||||
prop: 'time', label: '领用日期', align: 'center',
|
||||
prop: 'time', label: '入账日期', align: 'center',
|
||||
filter: parseTime,
|
||||
},
|
||||
{ prop: 'num', label: '数量', align: 'center' },
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
<template>
|
||||
<div style="width: 100%;">
|
||||
<Container name="趋势图" icon="cockpitItemIcon" size="operatingLarge" topSize="large">
|
||||
<Container :name="name" icon="cockpitItemIcon" size="operatingLarge" topSize="large">
|
||||
<!-- 1. 移除 .kpi-content 的固定高度,改为自适应 -->
|
||||
<div class="kpi-content" style="padding: 14px 16px; display: flex;width: 100%;">
|
||||
<div class="bottom" style="height: 420px; display: flex; width: 100%;background-color: rgba(249, 252, 255, 1);">
|
||||
<!-- <top-item /> -->
|
||||
<costBar />
|
||||
<costBar :yName="yName" :dateData="dateData" />
|
||||
|
||||
</div>
|
||||
</div>
|
||||
@@ -25,6 +25,18 @@ export default {
|
||||
type: Array,
|
||||
default: () => [] // 默认空数组,避免报错
|
||||
},
|
||||
dateData: { // 接收父组件传递的设备数据数组
|
||||
type: Array,
|
||||
default: () => {} // 默认空数组,避免报错
|
||||
},
|
||||
yName: { // 接收父组件传递的设备数据数组
|
||||
type: String,
|
||||
default: () => '' // 默认空数组,避免报错
|
||||
},
|
||||
name: { // 接收父组件传递的设备数据数组
|
||||
type: String,
|
||||
default: () => '趋势图' // 默认空数组,避免报错
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
@@ -43,123 +55,8 @@ export default {
|
||||
// 初始化图表(若需展示图表,需在模板中添加对应 DOM)
|
||||
// this.$nextTick(() => this.updateChart())
|
||||
},
|
||||
beforeDestroy() {
|
||||
// 销毁图表,避免内存泄漏
|
||||
if (this.chart) {
|
||||
this.chart.dispose()
|
||||
this.chart = null
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
updateChart() {
|
||||
// 注意:原代码中图表依赖 id 为 "productionStatusChart" 的 DOM,需在模板中补充,否则会报错
|
||||
// 示例:在 Container 内添加 <div id="productionStatusChart" style="height: 200px;"></div>
|
||||
if (!document.getElementById('productionStatusChart')) return
|
||||
|
||||
if (this.chart) this.chart.dispose()
|
||||
this.chart = echarts.init(document.getElementById('productionStatusChart'))
|
||||
|
||||
const data = [
|
||||
this.productionOverviewVo.input || 0,
|
||||
this.productionOverviewVo.output || 0,
|
||||
this.productionOverviewVo.ng || 0,
|
||||
this.productionOverviewVo.lowValue || 0,
|
||||
this.productionOverviewVo.scrap || 0,
|
||||
this.productionOverviewVo.inProcess || 0,
|
||||
this.productionOverviewVo.engineer || 0
|
||||
]
|
||||
|
||||
const option = {
|
||||
type: 'bar',
|
||||
grid: { left: 51, right: 40, top: 50, bottom: 45 },
|
||||
tooltip: {
|
||||
trigger: 'axis',
|
||||
axisPointer: { type: 'shadow' },
|
||||
className: 'production-status-chart-tooltip'
|
||||
},
|
||||
xAxis: {
|
||||
type: 'category',
|
||||
offset: 8,
|
||||
data: ['投入', '产出', '待判', '低价值', '报废', '在制', '实验片'],
|
||||
axisTick: { show: false },
|
||||
axisLine: { show: true, onZero: false, lineStyle: { color: '#00E8FF' } },
|
||||
axisLabel: {
|
||||
color: 'rgba(255,255,255,0.7)',
|
||||
fontSize: 12,
|
||||
interval: 0,
|
||||
width: 38,
|
||||
overflow: 'break'
|
||||
}
|
||||
},
|
||||
yAxis: {
|
||||
type: 'value',
|
||||
name: '单位/片',
|
||||
nameTextStyle: { color: 'rgba(255,255,255,0.7)', fontSize: 14, align: 'left' },
|
||||
min: () => 0,
|
||||
max: (value) => Math.ceil(value.max),
|
||||
scale: true,
|
||||
axisTick: { show: false },
|
||||
axisLabel: { color: 'rgba(255,255,255,0.7)', fontSize: 12 },
|
||||
splitLine: { lineStyle: { color: 'RGBA(24, 88, 100, 0.6)', type: 'dashed' } },
|
||||
axisLine: { show: true, lineStyle: { color: '#00E8FF' } }
|
||||
},
|
||||
series: [
|
||||
{
|
||||
type: 'pictorialBar',
|
||||
label: { show: true, position: 'top', distance: -3, color: '#89CDFF', fontSize: 11 },
|
||||
symbolSize: [20, 8],
|
||||
symbolOffset: [0, 5],
|
||||
z: 20,
|
||||
itemStyle: {
|
||||
borderColor: '#3588C7',
|
||||
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
|
||||
{ offset: 0, color: 'RGBA(22, 89, 98, 1)' },
|
||||
{ offset: 1, color: '#3588C7' }
|
||||
])
|
||||
},
|
||||
data: data
|
||||
},
|
||||
{
|
||||
type: 'bar',
|
||||
barWidth: 20,
|
||||
itemStyle: {
|
||||
borderWidth: 1,
|
||||
borderColor: '#3588C7',
|
||||
opacity: 0.8,
|
||||
color: {
|
||||
x: 0, y: 0, x2: 0, y2: 1,
|
||||
type: 'linear',
|
||||
global: false,
|
||||
colorStops: [
|
||||
{ offset: 0, color: 'rgba(73,178,255,0)' },
|
||||
{ offset: 0.5, color: 'rgba(0, 232, 255, .5)' },
|
||||
{ offset: 1, color: 'rgba(0, 232, 255, 1)' }
|
||||
]
|
||||
}
|
||||
},
|
||||
tooltip: { show: false },
|
||||
data: data
|
||||
},
|
||||
{
|
||||
type: 'pictorialBar',
|
||||
symbolSize: [20, 8],
|
||||
symbolOffset: [0, -4],
|
||||
z: 12,
|
||||
symbolPosition: 'end',
|
||||
itemStyle: {
|
||||
borderColor: 'rgba(0, 232, 255, 1)',
|
||||
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
|
||||
{ offset: 0, color: 'RGBA(22, 89, 98, 1)' },
|
||||
{ offset: 1, color: '#3588C7' }
|
||||
])
|
||||
},
|
||||
tooltip: { show: false },
|
||||
data: data
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
this.chart.setOption(option)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
<div class="middle-line"></div>
|
||||
<div class="value-item">
|
||||
<div class="number">{{ item.currentValue }}</div>
|
||||
<div class="title">当前值</div>
|
||||
<div class="title">实际值</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 进度条 + 完成率 -->
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
<div class="number" :style="{ color: item.flag === 1 ? '#36B58A' : '#F9A44A' }">
|
||||
{{ item.value }}
|
||||
</div>
|
||||
<div class="title">当前值</div>
|
||||
<div class="title">实际值</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="progress-yield-group">
|
||||
|
||||
@@ -73,16 +73,16 @@ export default {
|
||||
methods: {
|
||||
// 提取核心成本类型(仅保留“原片”“加工”等,去掉“成本”二字)
|
||||
extractCoreCostType(name) {
|
||||
// 匹配“前缀(含分公司/工厂/区域等)+ 核心词 + 任意后缀”,提取中间核心词
|
||||
// 匹配“前缀(含分公司/工厂/区域等)+ 核心词 + 后缀”,提取核心词+后缀
|
||||
// 兼容后缀:成本、费用、支出、损耗等,前缀:XX分公司、XX工厂、XX区域等
|
||||
const match = name.match(/(分公司)\s*([^,。;!?]+?)\s*(成本)/);
|
||||
if (match) {
|
||||
return match[2].trim(); // 提取中间核心词,去除前后空格
|
||||
// 保留核心词+后缀(去除前后空格)
|
||||
return (match[2] + match[3]).trim();
|
||||
}
|
||||
|
||||
// 通用匹配:无明确前缀标识时,提取“最后一个连续汉字后缀”前的内容
|
||||
const generalMatch = name.match(/(.+?)(?=[\u4e00-\u9fa5]{2,}$)/);
|
||||
return generalMatch ? generalMatch[1].trim() : name.trim();
|
||||
// 通用匹配:无明确前缀时,保留完整内容(原逻辑会去除末尾2个以上汉字,此处修改为保留全部)
|
||||
return name.trim();
|
||||
},
|
||||
// 提取地名(成本类型前的核心地区名)
|
||||
extractLocation(name) {
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
<div class="number" :style="{ color: getColorByFlag(item.flag) }">
|
||||
{{ item.value || 0 }}
|
||||
</div>
|
||||
<div class="title">当前值</div>
|
||||
<div class="title">实际值</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 进度条 + 完成率 -->
|
||||
@@ -35,7 +35,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="yield">
|
||||
<span class="progress-percent">完成率</span>
|
||||
<span class="progress-percent" :style="{ color: getColorByFlag(item.flag) }">完成率</span>
|
||||
<!-- 完成率:动态颜色 + 百分比格式 -->
|
||||
<span class="progress-percent progress-value" :style="{ color: getColorByFlag(item.flag) }">
|
||||
{{ getProportionPercent(item.proportion) }}%
|
||||
@@ -134,7 +134,7 @@ export default {
|
||||
getColorByFlag(flag, isProgressBar = false) {
|
||||
const colorMap = {
|
||||
1: {
|
||||
text: 'rgba(103, 103, 103, 0.79)',
|
||||
text: 'rgba(54, 181, 138, 1)',
|
||||
progress: 'rgba(103, 103, 103, 0.5)' // 进度条颜色稍浅
|
||||
},
|
||||
0: {
|
||||
|
||||
@@ -63,7 +63,7 @@ export default {
|
||||
interval: 0,
|
||||
padding: [5, 0, 0, 0] // 标签向下偏移,避免与柱子底部重叠
|
||||
},
|
||||
data: ['漳州', '桐城', '合肥', '宜兴', '自贡', '洛阳']
|
||||
data: ['6月', '7月', '8月', '9月', '10月', '11月']
|
||||
}
|
||||
],
|
||||
yAxis: [
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<div class="line"></div>
|
||||
<div class="right">
|
||||
<div class="number">{{ item.currentValue }}</div>
|
||||
<div class="title">当前值</div>
|
||||
<div class="title">实际值</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 进度条和百分比 -->
|
||||
|
||||
Reference in New Issue
Block a user