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
| <template>
| <div class="wmsStockBoardabc-container">
| <el-card class="full-table" shadow="hover" style="margin-top: 5px">
| <div class="task_echrts" style="height: 100%" ref="inOutLine"></div>
| </el-card>
| </div>
| </template>
|
| <script lang="ts" setup="" name="wmsStockBoardabc">
| import { ref,onMounted, nextTick, reactive, onUnmounted ,markRaw,onActivated,watch} from "vue";
| import * as echarts from 'echarts';
| import { ElMessageBox, ElMessage } from "element-plus";
| import { wmsStockPassMap, } from '/@/api/main/inventoryWarning/inventoryWarning';
|
|
| /***************************************************[出入库库存推移图操作]开始***************************************************/
|
| const loadingwmsStockBoardabc = ref(false);
| const disabled_btnwmsStockBoardabc = ref(false);
|
| import { useTagsViewRoutes } from '/@/stores/tagsViewRoutes';
| import { storeToRefs } from 'pinia';
| const storesTagsViewRoutes = useTagsViewRoutes();
| const { isTagsViewCurrenFull } = storeToRefs(storesTagsViewRoutes);
|
| /***************************************************[出入库库存推移图]开始***************************************************/
|
| // 查询出入库库存推移图
| const handleQuerywmsStockBoardabc = async () => {
| loadingwmsStockBoardabc.value = true;
| disabled_btnwmsStockBoardabc.value = true;
| var res = await wmsStockPassMap();
| if(res.data.type=="success"){
| let arr1: any[] = [];
| let arr2: any = [];
| let arr3: any = [];
| let arr4: any[] = [];
| let result = res.data.result || [];
| result.forEach((item:any) => {
| arr1.push(item.aveStockNum)
| arr2.push(item.inWare)
| arr3.push(item.outWare)
| arr4.push(item.stockNum)
| })
| nextTick(() => {
| setTimeout(() => {
| initLineChart(arr1,arr2,arr3,arr4);
| }, 500);
| });
| }
| loadingwmsStockBoardabc.value = false;
| disabled_btnwmsStockBoardabc.value = false;
| };
| handleQuerywmsStockBoardabc();
|
| // 折线图
| const state = reactive({
| global: {
| homeChartOne: null,
| dispose: [null, '', undefined],
| } as any,
| myCharts: [] as EmptyArrayType,
| charts: {
| theme: '',
| bgColor: '',
| color: '#303133',
| },
| });
| const inOutLine = ref();
| const initLineChart = (arr1:any,arr2:any,arr3:any,arr4:any) => {
| if (!state.global.dispose.some((b: any) => b === state.global.homeChartOne)) state.global.homeChartOne.dispose();
| state.global.homeChartOne = markRaw(echarts.init(inOutLine.value, state.charts.theme));
| const option = {
| backgroundColor: state.charts.bgColor,
| title: {
| text: '出入库库存推移图',
| x: 'left',
| textStyle: { fontSize: '15', color: state.charts.color },
| },
| grid: { top: 70, right: 20, bottom: 30, left: 30 },
| tooltip: { trigger: 'axis' },
| legend: { data: ['平均', '入库','出库', '库存'], right: 0 },
| xAxis: {
| data: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
| },
| yAxis: [
| {
| type: 'value',
| name: '单位',
| splitLine: { show: true, lineStyle: { type: 'dashed', color: '#f5f5f5' } },
| },
| ],
| series: [
| {
| name: '平均',
| type: 'line',
| symbolSize: 6,
| symbol: 'circle',
| smooth: true,
| // data: [0, 51.1, 40.4, 35.1, 23.3, 63.3, 43.3, 51.1, 30.4, 45.1, 33.3, 20],
| data: arr1,
| lineStyle: { color: '#fe9a8b' },
| itemStyle: { color: '#fe9a8b', borderColor: '#fe9a8b' },
| areaStyle: {
| color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
| { offset: 0, color: '#fe9a8bb3' },
| { offset: 1, color: '#fe9a8b03' },
| ]),
| },
| },
| {
| name: '入库',
| type: 'line',
| symbolSize: 6,
| symbol: 'circle',
| smooth: true,
| // data: [0, 54.1, 8.2, 25.5, 62.4, 32.4, 52.4, 54.1, 10.2, 35.5, 12.4, 0],
| data: arr2,
| lineStyle: { color: '#9E87FF' },
| itemStyle: { color: '#9E87FF', borderColor: '#9E87FF' },
| areaStyle: {
| color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
| { offset: 0, color: '#9E87FFb3' },
| { offset: 1, color: '#9E87FF03' },
| ]),
| },
| emphasis: {
| itemStyle: {
| color: {
| type: 'radial',
| x: 0.5,
| y: 0.5,
| r: 0.5,
| colorStops: [
| { offset: 0, color: '#9E87FF' },
| { offset: 0.4, color: '#9E87FF' },
| { offset: 0.5, color: '#fff' },
| { offset: 0.7, color: '#fff' },
| { offset: 0.8, color: '#fff' },
| { offset: 1, color: '#fff' },
| ],
| },
| borderColor: '#9E87FF',
| borderWidth: 2,
| },
| },
| },
| {
| name: '出库',
| type: 'line',
| symbolSize: 6,
| symbol: 'circle',
| smooth: true,
| // data: [0, 24.1, 7.2, 15.5, 42.4, 42.4, 42.4, 24.1, 7.2, 15.5, 42.4, 0],
| data: arr3,
| areaStyle: {
| color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
| { offset: 0, color: 'rgba(250,180,101,0.3)' },
| { offset: 1, color: 'rgba(250,180,101,0)' },
| ]),
| shadowColor: 'rgba(250,180,101,0.2)',
| shadowBlur: 20,
| },
| lineStyle: { color: '#FF8000' },
| itemStyle: { color: '#FF8000', borderColor: '#FF8000' },
| emphasis: {
| itemStyle: {
| color: {
| type: 'radial',
| x: 0.5,
| y: 0.5,
| r: 0.5,
| colorStops: [
| { offset: 0, color: '#FF8000' },
| { offset: 0.4, color: '#FF8000' },
| { offset: 0.5, color: '#fff' },
| { offset: 0.7, color: '#fff' },
| { offset: 0.8, color: '#fff' },
| { offset: 1, color: '#fff' },
| ],
| },
| borderColor: '#FF8000',
| borderWidth: 2,
| },
| },
| },
| {
| name: '库存',
| type: 'line',
| symbolSize: 6,
| symbol: 'circle',
| smooth: true,
| // data: [0, 54.1, 6.2, 25.5, 32.4, 42.4, 52.4, 34.1, 8.2, 45.5, 22.4, 0],
| data: arr4,
| areaStyle: {
| color: new echarts.graphic.LinearGradient(
| 0,
| 0,
| 0,
| 1,
| [
| { offset: 0, color: 'rgba(199, 237, 250,0.5)' },
| { offset: 1, color: 'rgba(199, 237, 250,0.2)' },
| ],
| false
| ),
| },
| lineStyle: { color: '#3bbc86' },
| itemStyle: { color: '#3bbc86', borderColor: '#3bbc86' },
| emphasis: {
| itemStyle: {
| color: {
| type: 'radial',
| x: 0.5,
| y: 0.5,
| r: 0.5,
| colorStops: [
| { offset: 0, color: '#3bbc86' },
| { offset: 0.4, color: '#3bbc86' },
| { offset: 0.5, color: '#fff' },
| { offset: 0.7, color: '#fff' },
| { offset: 0.8, color: '#fff' },
| { offset: 1, color: '#fff' },
| ],
| },
| borderColor: '#3bbc86',
| borderWidth: 2,
| },
| },
| },
| ],
| };
| state.global.homeChartOne.setOption(option);
| state.myCharts.push(state.global.homeChartOne);
| };
|
| // 批量设置 echarts resize
| const initEchartsResizeFun = () => {
| nextTick(() => {
| for (let i = 0; i < state.myCharts.length; i++) {
| setTimeout(() => {
| state.myCharts[i].resize();
| }, i * 1000);
| }
| });
| };
| // 批量设置 echarts resize
| const initEchartsResize = () => {
| window.addEventListener('resize', initEchartsResizeFun);
| };
| // 页面加载时
| onMounted(() => {
| initEchartsResize();
| });
| // 由于页面缓存原因,keep-alive
| onActivated(() => {
| initEchartsResizeFun();
| });
| // 监听 pinia 中的 tagsview 开启全屏变化,重新 resize 图表,防止不出现/大小不变等
| watch(
| () => isTagsViewCurrenFull.value,
| () => {
| initEchartsResizeFun();
| }
| );
|
| </script>
| <style scoped>
| :deep(.el-input),
| :deep(.el-select),
| :deep(.el-input-number) {
| width: 100%;
| }
| .task_echrts {
| width: 100%;
| height: 500px;
| background: #fff;
| border-radius: 10px;
| }
| </style>
|
|