-
@@ -15,157 +14,124 @@
@@ -391,14 +311,4 @@ export default {
diff --git a/src/views/home/components/pieChart.vue b/src/views/home/components/pieChart.vue
index ef154d82..0145c423 100644
--- a/src/views/home/components/pieChart.vue
+++ b/src/views/home/components/pieChart.vue
@@ -17,21 +17,35 @@ export default {
// // 验证:ref 名不能为空,确保有效
// return value.trim() !== '';
// }
- }
+ },
+ pieData: {
+ type: Object,
+ default: () => { } // 默认空数组,避免报错
+ },
},
- components: {},
data() {
return {};
},
computed: {},
+ watch: {
+ // 监听 pieData 变化,只要数据变了,就更新图表
+ pieData: {
+ handler() {
+ this.initData(); // 直接调用更新,无需判断 myChart 是否存在
+ },
+ deep: true,
+ immediate: true // 初始化时立即执行
+ },
+ },
mounted() {
this.$nextTick(() => {
- this.initData();
+ this.initChart(); // 只负责初始化图表实例
});
},
methods: {
initData() {
- // 2. 动态获取 DOM:通过 props 中的 chartRef 拿到对应的 ref 元素
+ console.log(this.pieData,'this.pieData.value');
+
const chartDom = this.$refs[this.chartRef];
if (!chartDom) {
console.error(`图表容器未找到!请确认父组件传递的 chartRef 为 "${this.chartRef}"`);
@@ -94,7 +108,7 @@ export default {
labelLine: {
show: true,
length: 0,
- length2: 30,
+ length2: 10,
lineStyle: {
color: (params) => customColors[params.dataIndex]
}
@@ -104,7 +118,7 @@ export default {
},
data: [
{
- value: 1048, name: '单镀面板',
+ value: this.pieData?.value || 0, name: '单镀面板',
label: {
normal: {
align: 'left',
@@ -133,7 +147,9 @@ export default {
}
},
labelLine: {
- lineStyle: { color: 'rgba(39, 96, 255, 1)' }
+ lineStyle: { color: 'rgba(39, 96, 255, 1)' },
+ length: 10,
+ length2: 20,
},
itemStyle: { color: 'rgba(39, 96, 255, 1)' }
},
@@ -168,8 +184,8 @@ export default {
},
labelLine: {
length: 0,
- length2: 50,
- lineStyle: { color: 'rgba(40, 138, 255, 1)' }
+ length2: 10,
+ lineStyle: { color: 'rgba(40, 138, 255, 1)' },
},
itemStyle: { color: 'rgba(40, 138, 255, 1)' }
},
@@ -203,7 +219,9 @@ export default {
}
},
labelLine: {
- lineStyle: { color: 'rgba(118, 218, 190, 1)' }
+ lineStyle: { color: 'rgba(118, 218, 190, 1)' },
+ length: 0,
+ length2: 10,
},
itemStyle: { color: 'rgba(118, 218, 190, 1)' }
},
@@ -237,7 +255,9 @@ export default {
}
},
labelLine: {
- lineStyle: { color: 'rgba(255, 206, 106, 1)' }
+ lineStyle: { color: 'rgba(255, 206, 106, 1)' },
+ length: 10,
+ length2: 10,
},
itemStyle: { color: 'rgba(255, 206, 106, 1)' }
}
diff --git a/src/views/home/components/premProdStatus.vue b/src/views/home/components/premProdStatus.vue
index e2ecf3ae..140ef480 100644
--- a/src/views/home/components/premProdStatus.vue
+++ b/src/views/home/components/premProdStatus.vue
@@ -5,7 +5,7 @@
@@ -28,10 +28,10 @@
@@ -54,11 +54,11 @@ export default {
components: { Container, topItem, coreBottomBar, pieChart, pieChartTwo },
// mixins: [resize],
props: {
- leftEqInfoData: { // 接收父组件传递的设备数据数组
- type: Array,
- default: () => [] // 默认空数组,避免报错
+ premiumProduct: { // 接收父组件传递的设备数据数组
+ type: Object,
+ default: () => {} // 默认空数组,避免报错
},
- productionOverviewVo: { // 恢复生产概览数据(原代码注释了,需根据实际需求保留)
+ salesProportion: { // 恢复生产概览数据(原代码注释了,需根据实际需求保留)
type: Object,
default: () => ({})
}
@@ -66,20 +66,22 @@ export default {
data() {
return {
chart: null,
+ monthPieData: {},
+ yearPieData:{},
parentItemList: [
{
name: "月度",
- targetValue: 80,
- value: 76,
- proportion: 95,
+ targetValue: 0,
+ value: 0,
+ proportion: 0,
route: 'profitAnalysis',
- completed: 0 // 未达目标值,不达标
+ completed: 1 // 未达目标值,不达标
},
{
name: "年度",
- targetValue: 900,
- value: 920,
- proportion: 102.2,
+ targetValue: 0,
+ value: 0,
+ proportion: 0,
route: 'profitAnalysis',
completed: 1 // 超出目标值,达标
}
@@ -87,134 +89,68 @@ export default {
}
},
watch: {
- productionOverviewVo: {
+ salesProportion: {
handler(newValue, oldValue) {
- this.updateChart()
+ console.log('salesProportion',newValue);
+
+ this.getPieData()
},
deep: true // 若对象内属性变化需触发,需加 deep: true
}
},
+ computed: {
+ formattedPremiumProductList() {
+ const premiumProductData = this.premiumProduct || {};
+
+ const nameToKeyMap = {
+ "月度": "month",
+ "年度": "year"
+ };
+
+ return this.parentItemList.map(item => {
+ const key = nameToKeyMap[item.name];
+
+ if (key && premiumProductData[key]) {
+ const periodData = premiumProductData[key];
+
+ let completed = 0;
+
+ // 新增:判断三个值是否都为0
+ const allZeros = periodData.real === 0 &&
+ periodData.target === 0 &&
+ periodData.rate === 0;
+
+ if (allZeros) {
+ completed = 1;
+ } else if (periodData.rate !== null && periodData.rate !== undefined) {
+ completed = periodData.rate >= 1 ? 1 : 0;
+ }
+
+ return {
+ ...item,
+ value: periodData.real,
+ targetValue: periodData.target,
+ proportion: periodData.rate !== null && periodData.rate !== undefined
+ ? Math.round(periodData.rate * 100)
+ : 0,
+ completed: completed,
+ };
+ }
+
+ return item;
+ });
+ }
+ },
mounted() {
// 初始化图表(若需展示图表,需在模板中添加对应 DOM)
// this.$nextTick(() => this.updateChart())
},
- beforeDestroy() {
- // 销毁图表,避免内存泄漏
- if (this.chart) {
- this.chart.dispose()
- this.chart = null
- }
- },
methods: {
- updateChart() {
- // 注意:原代码中图表依赖 id 为 "productionStatusChart" 的 DOM,需在模板中补充,否则会报错
- // 示例:在 Container 内添加
- if (!document.getElementById('productionStatusChart')) return
+ getPieData() {
+ this.monthPieData = this.salesProportion ? this.salesProportion.month : {}
+ this.yearPieData = this.salesProportion ? this.salesProportion.year : {}
+ console.log('this.monthPieData', this.monthPieData, this.yearPieData);
- 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)
}
}
}
@@ -392,16 +328,3 @@ export default {
}
-
-
diff --git a/src/views/home/components/profitBar.vue b/src/views/home/components/profitBar.vue
index 925380ca..d6318e02 100644
--- a/src/views/home/components/profitBar.vue
+++ b/src/views/home/components/profitBar.vue
@@ -118,8 +118,20 @@ export default {
yAxisIndex: 0,
barWidth: 18,
itemStyle: {
- color: '#2889FF',
- borderRadius: [4, 4, 0, 0]
+ // 移除多余的 normal 层级,直接配置 color 渐变
+ color: {
+ type: 'linear',
+ x: 0,
+ y: 0,
+ x2: 0,
+ y2: 1,
+ colorStops: [
+ { offset: 0, color: 'rgba(130, 204, 255, 1)' },
+ { offset: 1, color: 'rgba(75, 157, 255, 1)' }
+ ]
+ },
+ borderRadius: [4, 4, 0, 0],
+ borderWidth: 0
},
data: targetData.map(item => item.targetValue)
},
diff --git a/src/views/home/components/profitOverview.vue b/src/views/home/components/profitOverview.vue
index 8e90ae33..87df1aa4 100644
--- a/src/views/home/components/profitOverview.vue
+++ b/src/views/home/components/profitOverview.vue
@@ -1,6 +1,6 @@
-
+
diff --git a/src/views/home/components/psiLineBar.vue b/src/views/home/components/psiLineBar.vue
index 1038d104..485b013c 100644
--- a/src/views/home/components/psiLineBar.vue
+++ b/src/views/home/components/psiLineBar.vue
@@ -151,9 +151,8 @@ export default {
fontSize: 12,
align: 'right'
},
- min: 0,
- max: (value) => value.max > 0 ? Math.ceil(value.max * 1.1) : 10,
- scale: false,
+ scale: true,
+ splitNumber: 4,
axisTick: { show: false },
axisLabel: {
color: 'rgba(0, 0, 0, 0.45)',
@@ -162,7 +161,6 @@ export default {
},
splitLine: { lineStyle: { color: 'rgba(0, 0, 0, 0.15)' } },
axisLine: { lineStyle: { color: 'rgba(0, 0, 0, 0.15)' } },
- splitNumber: 4
},
{
type: 'value',
@@ -171,8 +169,8 @@ export default {
fontSize: 12,
align: 'left'
},
- min: 0,
- max: 100,
+ // min: 0,
+ // max: 100,
axisTick: { show: false },
axisLabel: {
color: 'rgba(0, 0, 0, 0.45)',
diff --git a/src/views/home/components/salesDataOverview.vue b/src/views/home/components/salesDataOverview.vue
index c694a3a2..22105c77 100644
--- a/src/views/home/components/salesDataOverview.vue
+++ b/src/views/home/components/salesDataOverview.vue
@@ -1,6 +1,6 @@
-
+
diff --git a/src/views/home/costComponents/baseTable.vue b/src/views/home/costComponents/baseTable.vue
index 03f9906b..15055f82 100644
--- a/src/views/home/costComponents/baseTable.vue
+++ b/src/views/home/costComponents/baseTable.vue
@@ -9,14 +9,14 @@
+ :header-cell-style="{ background: 'rgba(218, 226, 237, 1)', color: 'rgba(0, 0, 0, .6)', padding: '3px 2px' }"
+ :row-style="setRowStyle" :data="renderData" border style="width: 100%; background: transparent">
-
{{ scope.row[item.prop] | commonFilter(item.filter) }}
@@ -39,7 +39,7 @@ export default {
maxHeight: {
type: [Number, String], // 支持数字(如300)或字符串(如'300px')
required: false,
- default: 230 // 原固定值,作为默认 fallback
+ default: 200 // 原固定值,作为默认 fallback
},
tableData: {
type: Array,
@@ -130,7 +130,7 @@ export default {
if (divData.scrollTop + divData.clientHeight >= divData.scrollHeight - 1) {
// 滚动到底部后,重置到顶部(延迟一点更自然)
// setTimeout(() => {
- divData.scrollTop = 0
+ divData.scrollTop = 0
// }, 2000); // 停顿500ms后再从头滚动
}
}, 200) // 滚动速度(数值越小越快)
@@ -144,19 +144,19 @@ export default {
return {
background: '#F9FCFF',
color: 'rgba(87, 87, 87, 1)',
- height: 35 + 'px',
+ height: 35 + 'px',
lineHeight: 26 + 'px',
padding: 0,
- fontSize: 12 + 'px'
+ fontSize: 12 + 'px'
}
} else {
return {
background: 'rgba(239, 243, 248, 1)',
color: 'rgba(87, 87, 87, 1)',
- height: 35 + 'px',
- lineHeight: 26 + 'px',
+ height: 35 + 'px',
+ lineHeight: 26 + 'px',
padding: 0,
- fontSize: 12 + 'px'
+ fontSize: 12 + 'px'
}
}
},
@@ -171,19 +171,25 @@ export default {
diff --git a/src/views/home/costComponents/costBar.vue b/src/views/home/costComponents/costBar.vue
index b4da70cf..9a55ed08 100644
--- a/src/views/home/costComponents/costBar.vue
+++ b/src/views/home/costComponents/costBar.vue
@@ -1,33 +1,24 @@
-
-
-
目标
-
实际
-
-
@@ -51,15 +43,40 @@ import costBaseBarChart from './costBaseBarChart.vue';
export default {
name: "Container",
components: { costBaseBarChart },
- props: ['dateData','yName'],
+ props: ['dateData', 'yName', 'categoryData'],
data() {
return {
isDropdownShow: false,
- selectedProfit: '原料', // 默认选中"原料"
- profitOptions: ['原料', '其他选项1', '其他选项2'], // 可根据实际需求修改选项
+ selectedProfit: null, // 选中的名称,初始为null
};
},
- computed: {},
+ computed: {
+ // 从categoryData中提取name作为下拉选项
+ profitOptions() {
+ return this.categoryData.map(item => item.name) || [];
+ },
+ // 根据选中的名称筛选数据
+ filteredData() {
+ if (!this.selectedProfit || !this.categoryData.length) {
+ // 未选择时默认取第一个分类的数据(或空)
+ return this.categoryData[0] || {};
+ }
+ // 找到选中名称对应的分类数据
+ return this.categoryData.find(item => item.name === this.selectedProfit) || {};
+ }
+ },
+ watch: {
+ categoryData: {
+ handler() {
+ // 当分类数据变化时,若没有选中项则默认选中第一个
+ if (this.categoryData.length && !this.selectedProfit) {
+ this.selectedProfit = this.categoryData[0].name;
+ }
+ },
+ deep: true,
+ immediate: true
+ }
+ },
methods: {
selectProfit(item) {
this.selectedProfit = item;
@@ -82,6 +99,7 @@ export default {
+ -->
diff --git a/src/views/home/costComponents/profitImpactLine.vue b/src/views/home/costComponents/profitImpactLine.vue
index 45101fbb..fe3eaedf 100644
--- a/src/views/home/costComponents/profitImpactLine.vue
+++ b/src/views/home/costComponents/profitImpactLine.vue
@@ -1,7 +1,8 @@
@@ -11,12 +12,22 @@ import profitImpactLineChart from './profitImpactLineChart.vue';
export default {
name: "Container",
components: { profitImpactLineChart },
- props: ['dateData','yName'],
+ props: {
+ seriesData: {
+ type: Array,
+ default: () => []
+ },
+ xData: {
+ type: Array,
+ default: () => []
+ },
+ name: {
+ type: String,
+ default: () => { }
+ },
+ },
data() {
return {
- isDropdownShow: false,
- selectedProfit: '原料', // 默认选中"原料"
- profitOptions: ['原料', '其他选项1', '其他选项2'], // 可根据实际需求修改选项
};
},
computed: {},
diff --git a/src/views/home/costComponents/profitImpactLineChart.vue b/src/views/home/costComponents/profitImpactLineChart.vue
index 2120fc13..110d2ea8 100644
--- a/src/views/home/costComponents/profitImpactLineChart.vue
+++ b/src/views/home/costComponents/profitImpactLineChart.vue
@@ -11,10 +11,34 @@ export default {
return {};
},
props: {
- yName: {
- type: String,
- default: () => '元/㎡'
+ seriesData: {
+ type: Array,
+ default: () => []
},
+ xData: {
+ type: Array,
+ default: () => []
+ },
+ name: {
+ type: String,
+ default: () => { }
+ },
+ },
+ watch: {
+ // 监听 xData 变化,触发图表更新
+ xData: {
+ handler() {
+ this.$nextTick(() => this.initData());
+ },
+ deep: true // 深度监听数组内元素变化
+ },
+ // 监听 seriesData 变化,触发图表更新
+ seriesData: {
+ handler() {
+ this.$nextTick(() => this.initData());
+ },
+ deep: true // 深度监听数组内元素变化
+ }
},
mounted() {
this.$nextTick(() => {
@@ -69,7 +93,7 @@ export default {
interval: 0,
padding: [5, 0, 0, 0] // 标签向下偏移,避免与柱子底部重叠
},
- data: ['6月', '7月', '8月', '9月', '10月', '11月']
+ data: this.xData
}
],
yAxis: [
@@ -98,7 +122,7 @@ export default {
],
series: [
{
- name: '利润',
+ name: this.name,
type: 'line',
// yAxisIndex: 1,
lineStyle: {
@@ -118,7 +142,7 @@ export default {
{ offset: 1, color: 'rgba(40, 138, 255, 0)' }
])
},
- data: [200, 280, 180, 300, 220, 350],
+ data: this.seriesData,
symbol: 'circle',
symbolSize: 6
},
diff --git a/src/views/home/costComponents/profitLineChart.vue b/src/views/home/costComponents/profitLineChart.vue
index d92e07b6..0e5519f1 100644
--- a/src/views/home/costComponents/profitLineChart.vue
+++ b/src/views/home/costComponents/profitLineChart.vue
@@ -1,17 +1,17 @@
-
-
-
+
-
-
diff --git a/src/views/home/costComponents/single/topRightChart.vue b/src/views/home/costComponents/single/topRightChart.vue
index 37089cc0..a1081c6f 100644
--- a/src/views/home/costComponents/single/topRightChart.vue
+++ b/src/views/home/costComponents/single/topRightChart.vue
@@ -5,7 +5,7 @@
@@ -21,162 +21,79 @@ export default {
components: { Container, costBaseBarChart },
// mixins: [resize],
props: {
- leftEqInfoData: { // 接收父组件传递的设备数据数组
+ consumptionList: {
type: Array,
- default: () => [] // 默认空数组,避免报错
+ default: () => []
},
- name: { // 接收父组件传递的设备数据数组
+ name: {
type: String,
- default: () => '' // 默认空数组,避免报错
+ default: ''
},
- productionOverviewVo: { // 恢复生产概览数据(原代码注释了,需根据实际需求保留)
+ dateData: {
type: Object,
default: () => ({})
}
},
data() {
return {
- chart: null,
- parentItemList: [
- { unit: "利润总额", targetValue: 16, currentValue: 14.5, progress: 90 },
- { unit: "毛利率", targetValue: 16, currentValue: 15.2, progress: 85 },
- { unit: "单价", targetValue: 20, currentValue: 16, progress: 80 },
- { unit: "净价", targetValue: 20, currentValue: 16, progress: 80 },
- { unit: "销量", targetValue: 20, currentValue: 16, progress: 80 },
- { unit: "双镀面板", targetValue: 15, currentValue: 13.8, progress: 92 },
- { unit: "溢价产品销量", targetValue: 15, currentValue: 13.8, progress: 92 }
- ]
+ formattedList: [], // 格式化后的完整数据(含处理后的time)
+ seriesData: [], // value数组
+ xData: [] // 新增:存储格式化后的时间数组
}
},
watch: {
- productionOverviewVo: {
- handler(newValue, oldValue) {
- this.updateChart()
+ 'dateData.mode': {
+ handler() {
+ this.formatList()
},
- deep: true // 若对象内属性变化需触发,需加 deep: true
+ immediate: true
+ },
+ consumptionList: {
+ handler() {
+ this.formatList()
+ },
+ deep: true
}
},
mounted() {
// 初始化图表(若需展示图表,需在模板中添加对应 DOM)
// this.$nextTick(() => this.updateChart())
},
- beforeDestroy() {
- // 销毁图表,避免内存泄漏
- if (this.chart) {
- this.chart.dispose()
- this.chart = null
- }
- },
methods: {
- updateChart() {
- // 注意:原代码中图表依赖 id 为 "productionStatusChart" 的 DOM,需在模板中补充,否则会报错
- // 示例:在 Container 内添加
- if (!document.getElementById('productionStatusChart')) return
+ formatList() {
+ const { mode } = this.dateData
+ const flatList = this.consumptionList.flat().filter(item => item.time) // 扁平化+过滤无效数据
- if (this.chart) this.chart.dispose()
- this.chart = echarts.init(document.getElementById('productionStatusChart'))
+ // 处理数据:同时提取formattedTime、value
+ this.formattedList = flatList.map(item => ({
+ ...item,
+ formattedTime: this.formatTime(item.time, mode)
+ }))
- 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
- ]
+ // 提取value数组(原逻辑不变)
+ this.seriesData = this.formattedList.map(item => item.value)
- 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
- }
- ]
+ // 新增:提取格式化后的时间到timeArray(与valueArray顺序一一对应)
+ this.xData = this.formattedList.map(item => item.formattedTime)
+ },
+
+ formatTime(timestamp, mode) {
+ const date = new Date(timestamp)
+ const padZero = (num) => num.toString().padStart(2, '0')
+
+ switch (mode) {
+ case 1:
+ // mode=1:时分秒(HH:MM:SS)
+ return `${padZero(date.getHours())}:${padZero(date.getMinutes())}:${padZero(date.getSeconds())}`
+ case 2:
+ // mode=2:月日(MM-DD)
+ return `${padZero(date.getMonth() + 1)}-${padZero(date.getDate())}`
+ case 3:
+ // mode=3:年(YYYY)
+ return date.getFullYear().toString()
+ default:
+ return `${padZero(date.getMonth() + 1)}-${padZero(date.getDate())}`
}
-
- this.chart.setOption(option)
}
}
}
diff --git a/src/views/home/costComponents/singleTopSelect.vue b/src/views/home/costComponents/singleTopSelect.vue
index 88cc8601..47a156f9 100644
--- a/src/views/home/costComponents/singleTopSelect.vue
+++ b/src/views/home/costComponents/singleTopSelect.vue
@@ -14,58 +14,91 @@
{{ typeName }}
-
-
+
+
- 查询
+
+
+ 查询
+
-