gaoluyang
2025-10-15 e14d8f605015007082cd992830869dc0d62155c3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
<template>
    <div class="coal-blending-efficiency">
        <div class="page-header">
            <div class="search-form">
                <el-form :inline="true" :model="searchParams" class="demo-form-inline">
                    <el-form-item label="时间范围">
                        <el-date-picker
                            v-model="searchParams.dateRange"
                            type="daterange"
                            range-separator="至"
                            start-placeholder="开始日期"
                            end-placeholder="结束日期"
                            :shortcuts="dateShortcuts"
                        />
                    </el-form-item>
                    <el-form-item>
                        <el-button type="primary" @click="handleSearch" :loading="loading">查询</el-button>
                        <el-button @click="handleReset">重置</el-button>
                    </el-form-item>
                </el-form>
            </div>
        </div>
        
        <!-- 统计卡片区域 -->
        <div class="stats-cards">
            <div class="stat-card">
                <div class="card-icon">
                    <i class="el-icon-s-operation"></i>
                </div>
                <div class="card-content">
                    <div class="card-title">单位热值耗煤量</div>
                    <div class="card-value">{{ unitHeatValue.toFixed(2) }} kg/GJ</div>
                </div>
            </div>
            
            <div class="stat-card">
                <div class="card-icon">
                    <i class="el-icon-check-circle"></i>
                </div>
                <div class="card-content">
                    <div class="card-title">整体达标率</div>
                    <div class="card-value">{{ wholeStandardRate.toFixed(2) }}%</div>
                </div>
            </div>
            
            <div class="stat-card">
                <div class="card-icon">
                    <i class="el-icon-data-line"></i>
                </div>
                <div class="card-content">
                    <div class="card-title">平均发热量</div>
                    <div class="card-value">{{ averageFuel.toFixed(0) }} 大卡</div>
                </div>
            </div>
            
            <div class="stat-card">
                <div class="card-icon">
                    <i class="el-icon-files"></i>
                </div>
                <div class="card-content">
                    <div class="card-title">配方使用频次</div>
                    <div class="card-value">{{ frequency }} 次</div>
                </div>
            </div>
            
            <div class="stat-card">
                <div class="card-icon">
                    <i class="el-icon-s-data"></i>
                </div>
                <div class="card-content">
                    <div class="card-title">总批次</div>
                    <div class="card-value">{{ totalBatch }}</div>
                </div>
            </div>
        </div>
        
        <!-- 图表区域 -->
        <div class="charts-container">
            <!-- 达标率趋势图 -->
            <el-card class="chart-card">
                <template #header>
                    <div class="card-header">
                        <span>达标率趋势</span>
                    </div>
                </template>
                <div class="chart-wrapper">
                    <div ref="complianceChart" class="chart-content" style="height: 300px; width: 100%;"></div>
                </div>
            </el-card>
            
            <!-- 煤种发热量对比 -->
            <el-card class="chart-card">
                <template #header>
                    <div class="card-header">
                        <span>煤种发热量对比</span>
                    </div>
                </template>
                <div class="chart-wrapper">
                    <div ref="coalTypeHeatValueChart" class="chart-content" style="height: 300px; width: 100%;"></div>
                </div>
            </el-card>
            
 
            <!-- 加工得率分析 -->
            <el-card class="chart-card">
                <template #header>
                    <div class="card-header">
                        <span>加工得率分析</span>
                    </div>
                </template>
                <div class="chart-wrapper">
                    <div ref="yieldChart" class="chart-content" style="height: 300px; width: 100%;"></div>
                </div>
            </el-card>
            
            <!-- 成本结构图谱 -->
            <el-card class="chart-card">
                <template #header>
                    <div class="card-header">
                        <span>成本结构图谱</span>
                    </div>
                </template>
                <div class="chart-wrapper">
                    <div ref="costStructureChart" class="chart-content" style="height: 300px; width: 100%;"></div>
                </div>
            </el-card>
        </div>
    </div>
</template>
 
<script setup>
import { ref, onMounted, computed, nextTick } from 'vue'
import * as echarts from 'echarts'
import Echarts from '@/components/Echarts/echarts.vue'
import { ElMessage } from 'element-plus'
import { getReportStatistics, getReportTrend } from '@/api/productionScheduling/index.js'
import { processingRateAnalysis } from '@/api/productionScheduling/index.js'
import request from '@/utils/request'
 
// 成本结构图谱API函数 - 直接在组件内定义
const costStructure = (query) => {
  return request({
    url: '/productHome/costStructure',
    method: 'get',
    params: query
  })
}
 
// 煤种发热量对比API函数 - 根据接口文档定义
const coalTypeHeatValueComparison = (query) => {
  return request({
    url: '/productHome/coalTypeHeatValueComparison',
    method: 'get',
    params: query
  })
}
 
 
// 搜索参数
const searchParams = ref({
    dateRange: []
})
 
// 日期快捷选项
const dateShortcuts = [
    {
        text: '近7天',
        value: () => {
            const end = new Date()
            const start = new Date()
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 7)
            return [start, end]
        }
    },
    {
        text: '近30天',
        value: () => {
            const end = new Date()
            const start = new Date()
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 30)
            return [start, end]
        }
    },
    {
        text: '本月',
        value: () => {
            const end = new Date()
            const start = new Date(end.getFullYear(), end.getMonth(), 1)
            return [start, end]
        }
    }
]
 
// 统计数据
const unitHeatValue = ref(0)
const wholeStandardRate = ref(0)
const averageFuel = ref(0)
const frequency = ref(0)
const totalBatch = ref(0)
 
// 达标率趋势数据引用
const complianceChart = ref(null)
 
// 加工得率图表引用
const yieldChart = ref(null)
 
// 成本结构图表引用
const costStructureChart = ref(null)
 
// 煤种发热量对比图表引用
const coalTypeHeatValueChart = ref(null)
 
// Echarts组件图表不需要额外的引用变量,组件内部会处理图表初始化
// 移除未使用的图表引用变量,避免可能的冲突
 
// 达标率趋势数据 - 初始为空数据
const complianceTrendData = ref({
    Xkeys: [],
    Yvalues: []
})
 
// 加工得率分析数据 - 初始为空数据
const processingYieldData = ref({
    Xkeys: [],
    Yvalues: []
})
 
// 成本结构数据 - 初始为空数据
const costStructureData = ref([])
 
// 煤种发热量对比数据 - 初始为空数据
const coalTypeHeatValueData = ref([])
 
// 成本结构图谱初始化
const initCostStructureChart = () => {
    if (!costStructureChart.value) return
    
    console.log('初始化成本结构图表,数据:', costStructureData.value);
    const chart = echarts.init(costStructureChart.value);
    const option = {
        title: {
            show: costStructureData.value.length === 0, // 没数据才显示
            textStyle: {
                color: "grey",
                fontSize: 20,
            },
            text: "暂无数据",
            left: "center",
            top: "center",
        },
        tooltip: {
            trigger: 'item',
            // 根据API返回的数据结构格式化显示
            formatter: '{b}: {c} ({d}%)'
        },
        legend: {
            orient: 'vertical',
            left: 'right',
            top: 'center',
            textStyle: {
                fontSize: 12
            }
        },
        series: [
            {
                name: '成本结构',
                type: 'pie',
                radius: ['30%', '70%'],
                center: ['40%', '50%'],
                data: costStructureData.value.length > 0 
                    ? costStructureData.value.map(item => ({
                        name: item.name,
                        value: item.value
                    }))
                    : [],
                emphasis: {
                    itemStyle: {
                        shadowBlur: 10,
                        shadowOffsetX: 0,
                        shadowColor: 'rgba(0, 0, 0, 0.5)'
                    }
                },
                itemStyle: {
                    borderRadius: 4,
                    borderColor: '#fff',
                    borderWidth: 2
                },
                label: {
                    show: true,
                    formatter: '{b}\n{d}%'
                }
            }
        ]
    };
    chart.setOption(option);
    window.addEventListener('resize', () => {
        chart.resize();
    });
}
 
// 达标率趋势图初始化
const initComplianceChart = () => {
    if (!complianceChart.value) return
    
    const chart = echarts.init(complianceChart.value);
    const option = {
        title: {
            show: complianceTrendData.value.Yvalues.length === 0, // 没数据才显示
            textStyle: {
                color: "grey",
                fontSize: 20,
            },
            text: "暂无数据",
            left: "center",
            top: "center",
        },
        tooltip: {
            trigger: 'axis',
            formatter: '{b}<br/>达标率: {c}%'
        },
        grid: {
            left: '3%',
            right: '4%',
            bottom: '3%',
            containLabel: true
        },
        xAxis: {
            type: 'category',
            data: complianceTrendData.value.Xkeys || [],
            axisLabel: {
                rotate: 45
            }
        },
        yAxis: {
            type: 'value',
            name: '达标率 (%)',
            min: 0, // 固定最小值为0
            max: 100, // 固定最大值为100
            // 设置坐标轴标签格式为百分比
            axisLabel: {
                formatter: '{value}%'
            }
        },
        series: [
            {
                name: '达标率',
                type: 'line',
                smooth: true,
                data: complianceTrendData.value.Yvalues || [],
                itemStyle: {
                    color: '#409EFF'
                },
                // 添加标记点和标记线
                markPoint: {
                    data: [
                        { type: 'max', name: '最大值' },
                        { type: 'min', name: '最小值' }
                    ]
                },
                markLine: {
                    data: [
                        { type: 'average', name: '平均值' }
                    ]
                }
            }
        ]
    }
    chart.setOption(option);
    window.addEventListener('resize', () => {
        chart.resize();
    });
};
 
// 煤种发热量对比图初始化
const initCoalTypeHeatValueChart = () => {
    if (!coalTypeHeatValueChart.value) return
    
    console.log('初始化煤种发热量对比图表,数据:', coalTypeHeatValueData.value);
    const chart = echarts.init(coalTypeHeatValueChart.value);
    const option = {
        title: {
            show: coalTypeHeatValueData.value.length === 0, // 没数据才显示
            textStyle: {
                color: "grey",
                fontSize: 20,
            },
            text: "暂无数据",
            left: "center",
            top: "center",
        },
        tooltip: {
            trigger: 'axis',
            axisPointer: {
                type: 'shadow'
            },
            formatter: function(params) {
                return params[0].name + '<br/>发热量: ' + params[0].value + ' 大卡';
            }
        },
        grid: {
            left: '3%',
            right: '4%',
            bottom: '10%',
            containLabel: true
        },
        xAxis: {
            type: 'category',
            data: coalTypeHeatValueData.value.map(item => item.name) || [],
            axisLabel: {
                fontSize: 11,
                rotate: 45
            }
        },
        yAxis: {
            type: 'value',
            axisLabel: {
                fontSize: 11
            }
        },
        series: [
            {
                name: '发热量',
                type: 'bar',
                data: coalTypeHeatValueData.value.map(item => item.value) || [],
                itemStyle: {
                    color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
                        { offset: 0, color: '#409EFF' },
                        { offset: 1, color: '#79bbff' }
                    ])
                },
                barWidth: '60%',
                label: {
                    show: true,
                    position: 'top',
                    formatter: function(params) {
                        return params.value + '大卡';
                    }
                }
            }
        ]
    };
    chart.setOption(option);
    window.addEventListener('resize', () => {
        chart.resize();
    });
};
 
// 加工得率趋势图初始化
const initProcessingYieldChart = () => {
    if (!yieldChart.value) return
    
    console.log('初始化加工得率图表,数据:', processingYieldData.value);
    const chart = echarts.init(yieldChart.value);
    const option = {
        title: {
            show: processingYieldData.value.Yvalues.length === 0, // 没数据才显示
            textStyle: {
                color: "grey",
                fontSize: 20,
            },
            text: "暂无数据",
            left: "center",
            top: "center",
        },
        tooltip: {
            trigger: 'axis',
            formatter: '{b}<br/>得率: {c}%'
        },
        grid: {
            left: '3%',
            right: '4%',
            bottom: '3%',
            containLabel: true
        },
        xAxis: {
            type: 'category',
            data: processingYieldData.value.Xkeys || [],
            axisLabel: {
                rotate: 45
            }
        },
        yAxis: {
            type: 'value',
            name: '得率 (%)',
            min: 0,
            // 最大值改为数据中的最大值,并增加5%的余量
            max: processingYieldData.value.Yvalues && processingYieldData.value.Yvalues.length > 0 
                ? Math.ceil(Math.max(...processingYieldData.value.Yvalues) * 1.05) 
                : 100,
            // 设置坐标轴标签格式为百分比
            axisLabel: {
                formatter: '{value}%'
            }
        },
        series: [
            {
                name: '加工得率',
                type: 'line',
                smooth: true,
                data: processingYieldData.value.Yvalues || [],
                itemStyle: {
                    color: '#52C41A'
                },
                lineStyle: {
                    width: 3, // 增加线条宽度
                    color: '#52C41A'
                },
                showSymbol: true, // 显示标记点
                symbol: 'circle',
                symbolSize: 8, // 增加标记点大小
                // 添加标记点和标记线
                markPoint: {
                    data: [
                        { type: 'max', name: '最大值' },
                        { type: 'min', name: '最小值' }
                    ]
                },
                markLine: {
                    data: [
                        { type: 'average', name: '平均值' }
                    ]
                }
            }
        ]
    };
    chart.setOption(option, true); // 强制重新渲染
    window.addEventListener('resize', () => {
        chart.resize();
    });
};
 
// 煤种发热量对比图配置 - 使用API获取的数据
const calorificValueOptions = computed(() => ({
    title: {
        show: coalTypeHeatValueData.value.length === 0, // 没数据才显示
        textStyle: {
            color: "grey",
            fontSize: 20,
        },
        text: "暂无数据",
        left: "center",
        top: "center",
    },
    tooltip: {
        trigger: 'axis',
        axisPointer: {
            type: 'shadow'
        },
        formatter: '{b}<br/>发热量: {c} 大卡<br/>占比: {d}%'
    },
    grid: {
        left: '3%',
        right: '4%',
        bottom: '3%',
        containLabel: true
    },
    xAxis: {
        type: 'category',
        data: coalTypeHeatValueData.value.map(item => item.name) || [],
        axisLabel: {
            rotate: 45
        }
    },
    yAxis: {
        type: 'value',
        name: '发热量 (大卡)'
    },
    series: [
        {
            name: '发热量',
            type: 'bar',
            data: coalTypeHeatValueData.value.map(item => ({
                value: item.value,
                percent: item.percent
            })) || [],
            itemStyle: {
                color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
                    { offset: 0, color: '#FF6B81' },
                    { offset: 1, color: '#FF8E53' }
                ])
            },
            label: {
                show: true,
                position: 'top',
                formatter: function(params) {
                    // 使用原始数据中的percent值
                    const item = coalTypeHeatValueData.value.find(item => item.name === params.name);
                    return params.value + '大卡\n(' + (item && item.percent ? item.percent.toFixed(2) : '0') + '%)';
                }
            }
        }
    ]
}))
 
// 加工得率分析相关的配置已移除,现在使用手动初始化方式
 
// 成本结构图谱配置 - 使用API获取的数据
const costStructureOptions = computed(() => ({
    title: {
        show: costStructureData.value.length === 0, // 没数据才显示
        textStyle: {
            color: "grey",
            fontSize: 20,
        },
        text: "暂无数据",
        left: "center",
        top: "center",
    },
    tooltip: {
        trigger: 'item',
        // 根据API返回的数据结构格式化显示
        formatter: '{b}: {c} ({d}%)'
    },
    legend: {
        orient: 'vertical',
        left: 'left',
        textStyle: {
            fontSize: 12
        }
    },
    series: [
        {
            name: '成本结构',
            type: 'pie',
            radius: '60%',
            center: ['60%', '50%'],
            data: costStructureData.value.length > 0 
                ? costStructureData.value.map(item => ({
                    name: item.name,
                    value: item.value,
                    percent: item.percent
                }))
                : [],
            emphasis: {
                itemStyle: {
                    shadowBlur: 10,
                    shadowOffsetX: 0,
                    shadowColor: 'rgba(0, 0, 0, 0.5)'
                }
            },
            itemStyle: {
                borderRadius: 4,
                borderColor: '#fff',
                borderWidth: 2
            },
            // 设置标签格式化,显示占比
            label: {
                show: true,
                formatter: '{b}\n{d}%'
            }
        }
    ]
}))
 
// 查询数据
const loading = ref(false)
 
const handleSearch = async () => {
    try {
        loading.value = true
        // 构建请求参数
        const params = {
            entryDateStart: searchParams.value.dateRange && searchParams.value.dateRange[0] ?
                searchParams.value.dateRange[0].toISOString().split('T')[0] : '',
            entryDateEnd: searchParams.value.dateRange && searchParams.value.dateRange[1] ?
                searchParams.value.dateRange[1].toISOString().split('T')[0] : ''
        }
        console.log('搜索参数:', params)
        
        // 调用API获取报表统计数据
        const res = await getReportStatistics(params)
        
        if (res.code === 200 && res.data) {
            // 更新统计数据
            unitHeatValue.value = res.data.unitHeatValue || 0
            wholeStandardRate.value = res.data.wholeStandardRate || 0
            averageFuel.value = res.data.averageFuel || 0
            frequency.value = res.data.frequency || 0
            totalBatch.value = res.data.totalBatch || 0
        } else {
            throw new Error(res.msg || '获取数据失败')
        }
        
        // 调用API获取达标率趋势数据
        const trendRes = await getReportTrend(params)
        
        if (trendRes.code === 200 && trendRes.data && trendRes.data.length > 0) {
            // 预处理达标率趋势数据,确保value字段是有效的数字
            const Xkeys = []
            const Yvalues = []
            trendRes.data.forEach(item => {
                Xkeys.push(item.name || '')
                Yvalues.push(typeof item.value === 'number' ? item.value : parseFloat(item.value) || 0)
            })
            // 更新达标率趋势数据
            complianceTrendData.value = {
                Xkeys,
                Yvalues
            }
        } else {
            console.warn('获取达标率趋势数据失败:', trendRes.msg)
            // 设置空数据,显示暂无数据提示
            complianceTrendData.value = { Xkeys: [], Yvalues: [] }
        }
        
        // 调用API获取加工得率分析数据
        const yieldRes = await processingRateAnalysis(params)
        
        if (yieldRes.code === 200 && yieldRes.data && yieldRes.data.length > 0) {
            // 预处理加工得率数据
            const Xkeys = []
            const Yvalues = []
            yieldRes.data.forEach(item => {
                Xkeys.push(item.name || '')
                Yvalues.push(typeof item.value === 'number' ? item.value : parseFloat(item.value) || 0)
            })
            // 更新加工得率数据
            processingYieldData.value = {
                Xkeys,
                Yvalues
            }
        } else {
            console.warn('获取加工得率数据失败:', yieldRes.msg)
            // 设置空数据,显示暂无数据提示
            processingYieldData.value = { Xkeys: [], Yvalues: [] }
        }
        
        // 调用API获取成本结构数据
        const costRes = await costStructure(params)
        
        if (costRes.code === 200 && costRes.data && costRes.data.length > 0) {
            // 更新成本结构数据
            costStructureData.value = costRes.data
        } else {
            console.warn('获取成本结构数据失败:', costRes.msg)
            // 设置空数据,显示暂无数据提示
            costStructureData.value = []
        }
        
        // 调用API获取煤种发热量对比数据
        const coalValueRes = await coalTypeHeatValueComparison(params)
        
        if (coalValueRes.code === 200 && coalValueRes.data && coalValueRes.data.length > 0) {
            // 更新煤种发热量对比数据
            coalTypeHeatValueData.value = coalValueRes.data
        } else {
            console.warn('获取煤种发热量对比数据失败:', coalValueRes.msg)
            // 设置空数据,显示暂无数据提示
            coalTypeHeatValueData.value = []
        }
        
        // 数据更新后重新初始化图表
        nextTick(() => {
            initComplianceChart()
            initProcessingYieldChart()
            initCostStructureChart()
            initCoalTypeHeatValueChart()
        })
    } catch (error) {
        console.error('查询失败:', error)
        ElMessage.error('查询失败,请稍后重试')
    } finally {
        loading.value = false
    }
}
 
// 刷新数据
const handleRefresh = () => {
    ElMessage.info('正在刷新数据...')
    handleSearch()
}
 
// 导出数据
const handleExport = async () => {
    try {
        loading.value = true
        // 模拟导出操作
        await new Promise(resolve => setTimeout(resolve, 1000))
        
        ElMessage.success('数据导出成功')
    } catch (error) {
        console.error('导出失败:', error)
        ElMessage.error('导出失败,请稍后重试')
    } finally {
        loading.value = false
    }
}
 
// 重置搜索参数
const handleReset = () => {
    searchParams.value = {
        dateRange: []
    }
}
 
// 初始化页面
onMounted(() => {
    // 默认查询近7天数据
    const end = new Date()
    const start = new Date()
    start.setTime(start.getTime() - 3600 * 1000 * 24 * 7)
    searchParams.value.dateRange = [start, end]
    
    // 初始加载数据
    handleSearch()
    
    // 初始化图表
    nextTick(() => {
        initComplianceChart()
        initProcessingYieldChart()
        initCostStructureChart()
        initCoalTypeHeatValueChart()
    })
})
</script>
 
<style scoped>
.coal-blending-efficiency {
    padding: 20px;
}
 
.page-header {
    margin-bottom: 20px;
}
 
.page-header h2 {
    margin-bottom: 15px;
    font-size: 18px;
    font-weight: 600;
    color: #303133;
}
 
.stats-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
 
.stat-card {
    display: flex;
    padding: 20px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s, box-shadow 0.3s;
}
 
.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}
 
.card-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 24px;
    margin-right: 16px;
}
 
.stat-card:nth-child(1) .card-icon {
    background: #ECF5FF;
    color: #409EFF;
}
 
.stat-card:nth-child(2) .card-icon {
    background: #F0F9FF;
    color: #69B1FF;
}
 
.stat-card:nth-child(3) .card-icon {
    background: #F6FFED;
    color: #52C41A;
}
 
.stat-card:nth-child(4) .card-icon {
    background: #FFF7E6;
    color: #FAAD14;
}
 
.card-content {
    flex: 1;
}
 
.card-title {
    font-size: 14px;
    color: #606266;
    margin-bottom: 8px;
}
 
.card-value {
    font-size: 24px;
    font-weight: 600;
    color: #303133;
    margin-bottom: 4px;
}
 
.card-desc {
    font-size: 12px;
    color: #909399;
}
 
.charts-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(500px, 1fr));
    gap: 24px;
}
 
.chart-card {
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
}
 
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid #EBEEF5;
}
 
.card-header span {
    font-weight: 600;
    color: #303133;
}
 
.chart-wrapper {
    padding: 20px;
}
 
.cost-structure {
    grid-column: 1 / -1;
}
 
@media (max-width: 1200px) {
    .charts-container {
        grid-template-columns: 1fr;
    }
}
</style>