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
| <template>
| <div class="app-container">
| <el-row>
| <!-- <el-col>
| <div style="width: 100%; height: 60px; text-align: center; border-bottom: 2px solid #ccc">
| <h1>焊缝需求统计图表</h1>
| </div>
| </el-col> -->
| <el-col>
| <el-form :model="queryParams" ref="queryRef" :inline="true" label-width="90px">
| <el-row :gutter="20">
| <el-col :span="12">
| <el-form-item label="统计日期" style="width: 50%;">
| <el-date-picker
| v-model="totalDay"
| value-format="YYYY-MM"
| type="monthrange"
| range-separator="-"
| start-placeholder="开始日期"
| end-placeholder="结束日期"
| ></el-date-picker>
| </el-form-item>
| </el-col>
| <el-col :span="12" style="text-align: right;">
| <el-form-item>
| <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
| <el-button icon="Refresh" @click="resetQuery">重置</el-button>
| </el-form-item>
| </el-col>
| </el-row>
| </el-form>
| </el-col>
| <el-col>
| <div ref="chartRef" :style="{ width:width,height:height,border: '1px solid #ccc' }" v-loading="loading">
| <div style="text-align: center;margin-top: 50px;color: #999;">暂无数据</div>
| </div>
| </el-col>
| </el-row>
| </div>
| </template>
| <script setup name="WeldSeamEcharts">
| import * as echarts from 'echarts';
| import { weldSeamEchartsList} from "@/api/mainPlan/weldSeamEcharts/weldSeamEcharts";
| const totalDay = ref([]);
| const data = reactive({
| form: {},
| queryParams: {
| produceYear: null,
| produceMonth: null,
| },
| rules: {
| }
| });
| const { queryParams } = toRefs(data);
| const chartRef = ref(null);
| const height = ref(document.documentElement.clientHeight - 180 + "px");
| const width = ref(document.documentElement.clientWidth - 240 + "px");
|
| const showSearch = ref(false);
| const loading = ref(false);
|
| /* const dataList = [
| ['product', '南通-订单-管路', '南通-订单-气柜', '南通-预测-管路', '南通-预测-气柜', '南通-预测-管路1', '南通-预测-气柜1', '南通-预测-管路2', '南通-预测-气柜2', '南通-预测-管路3', '南通-预测-气柜3', '南通-预测-管路4', '南通-预测-气柜4'],
| ['4月', '43.3', '85.8', '93.7', '93.7', '43.3', '85.8', '43.3', '85.8', '93.7', '93.7', '43.3', '85.8'],
| ['5月', '43.3', '85.8', '93.7', '93.7', '43.3', '85.8', '43.3', '85.8', '93.7', '93.7', '43.3', '85.8'],
| ['6月', 86.4, 65.2, 82.5, 93.7],
| ['7月', 72.4, 53.9, 39.1, 93.7],
| ['8月', 72.4, 53.9, 39.1, 93.7],
|
| ] */
|
| // const series = [{ type: 'bar' }, { type: 'bar' }, { type: 'bar' }, { type: 'bar' }, { type: 'bar' }, { type: 'bar' }, { type: 'bar' }, { type: 'bar' }, { type: 'bar' }, { type: 'bar' }, { type: 'bar' }, { type: 'bar' }]
|
|
| let myChart = null;
|
| const renderChart = (data,series) => {
| // 初始化 ECharts 实例
| myChart = echarts.init(chartRef.value);
| const option = {
| legend: {
| width: 1000,
| top: 30,
| left: 'center',
| type: "scroll",
| itemGap: 30,//图例的上下间距
| // itemWidth: 10,//图例左侧图块的长度
| // padding: 5,
| },
| tooltip: {},
| dataset: {
| source: data
| },
| xAxis: { type: 'category' },
| yAxis: { name: '数量'},
| grid: { top:'15%',bottom:'5%'},
| series: series,
| title: {
| text: '各生产基地管路与气柜需求对比图',
| left: 'center',
| },
| toolbox: {
| show: true,
| feature: {
| saveAsImage: {},
| /* magicType: {
| show: true,
| type: ['line','bar','stack','tiled'],
| },
| restore: {//还原原始图表
| show: true
| }, */
| }
| }
| };
|
| // 使用配置项显示图表
| myChart.setOption(option);
| loading.value = false;
| };
|
| /** 搜索按钮操作 */
| function handleQuery() {
| showSearch.value = true;
| getList();
| }
|
| /** 重置按钮操作 */
| function resetQuery() {
| totalDay.value = [];
| // handleQuery();
| clearChart();
| showSearch.value = false;
| }
|
| function getList() {
| loading.value = true;
| clearChart();
| queryParams.value.params = {};
| if (null != totalDay.value && '' != totalDay.value) {
| queryParams.value.params["startDay"] = totalDay.value[0];
| queryParams.value.params["endDay"] = totalDay.value[1];
| }
| weldSeamEchartsList(queryParams.value).then(response => {
| let dataList = [];
| let series = [];
| dataList = response.data;
| if(response.data.length === 1){
| showSearch.value = false;
| }else{
| for(let i=0;i<response.data[0].length-1;i++){
| series.push({ type: 'bar' });
| }
| renderChart(dataList,series);
| }
| });
|
| }
|
| /**清除chart */
| function clearChart() {
| if (myChart) {
| myChart.dispose();
| myChart = null;
| chartRef.value.innerHTML = '<div style="text-align: center;margin-top: 50px;color: #999;">暂无数据</div>';
| }
| }
| </script>
|
|