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
| <template>
| <div>
| <PanelHeader title="出入库趋势" />
| <div class="main-panel panel-item-customers">
| <div class="filters-row">
|
| <ProductTypeSwitch v-model="productType" @change="handleFilterChange" />
| </div>
| <Echarts
| ref="chart"
| :chartStyle="chartStyle"
| :grid="grid"
| :legend="lineLegend"
| :series="lineSeries"
| :tooltip="tooltip"
| :xAxis="xAxis1"
| :yAxis="yAxis1"
| :options="{ backgroundColor: 'transparent', textStyle: { color: '#B8C8E0' } }"
| style="height: 260px"
| />
| </div>
| </div>
| </template>
|
| <script setup>
| import { ref, onMounted } from 'vue'
| import * as echarts from 'echarts'
| import Echarts from '@/components/Echarts/echarts.vue'
| import PanelHeader from './PanelHeader.vue'
| import ProductTypeSwitch from './ProductTypeSwitch.vue'
| import { productInOutAnalysis } from '@/api/viewIndex.js'
|
| const productType = ref(1) // 1=原材料 2=半成品 3=成品
|
| const chartStyle = { width: '100%', height: '130%' }
|
| const grid = {
| left: '3%',
| right: '4%',
| bottom: '3%',
| top: '16%',
| containLabel: true,
| }
|
| const lineLegend = {
| show: true,
| top: '2%',
| left: 'center',
| itemGap: 24,
| itemWidth: 12,
| itemHeight: 12,
| textStyle: { color: '#B8C8E0', fontSize: 14 },
| data: [
| { name: '出库', itemStyle: { color: 'rgba(11, 137, 254, 1)' } },
| { name: '入库', itemStyle: { color: 'rgba(11, 249, 254, 1)' } },
| ],
| }
|
| const xAxis1 = ref([
| {
| type: 'category',
| data: [],
| axisTick: { show: false },
| axisLine: { show: false, lineStyle: { color: 'rgba(184, 200, 224, 0.3)' } },
| axisLabel: { color: '#B8C8E0', fontSize: 12 },
| splitLine: { show: false, lineStyle: { type: 'dashed', color: 'rgba(184, 200, 224, 0.2)' } },
| },
| ])
|
| const yAxis1 = [
| {
| type: 'value',
| name: '单位: 件',
| nameTextStyle: { color: '#B8C8E0', fontSize: 12, padding: [0, 0, 0, 0] },
| axisLine: { show: false },
| axisTick: { show: false },
| axisLabel: { color: '#B8C8E0', fontSize: 12 },
| splitLine: { lineStyle: { color: '#B8C8E0' } },
| },
| ]
|
| const lineSeries = ref([
| {
| name: '出库',
| type: 'line',
| smooth: false,
| showSymbol: true,
| symbol: 'circle',
| symbolSize: 8,
| lineStyle: { color: 'rgba(11, 137, 254, 1)', width: 2 },
| itemStyle: { color: 'rgba(11, 137, 254, 1)', borderWidth: 0 },
| areaStyle: {
| color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
| { offset: 0, color: 'rgba(11, 137, 254, 0.40)' },
| { offset: 1, color: 'rgba(11, 137, 254, 0.05)' },
| ]),
| },
| data: [],
| emphasis: { focus: 'series' },
| },
| {
| name: '入库',
| type: 'line',
| smooth: false,
| showSymbol: true,
| symbol: 'circle',
| symbolSize: 8,
| lineStyle: { color: 'rgba(11, 249, 254, 1)', width: 2 },
| itemStyle: { color: 'rgba(11, 249, 254, 1)', borderWidth: 0 },
| areaStyle: {
| color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
| { offset: 0, color: 'rgba(11, 249, 254, 0.5)' },
| { offset: 1, color: 'rgba(11, 249, 254, 0.05)' },
| ]),
| },
| data: [],
| emphasis: { focus: 'series' },
| },
| ])
|
| const tooltip = {
| trigger: 'axis',
| axisPointer: { type: 'line' },
| borderWidth: 1,
| textStyle: { fontSize: 12 },
| formatter(params) {
| let result = params[0].axisValue + '<br/>'
| params.forEach((item) => {
| result += `${item.marker} ${item.seriesName}: ${item.value} 件<br/>`
| })
| return result
| },
| }
|
| const fetchData = () => {
| productInOutAnalysis({ type: productType.value })
| .then((res) => {
| if (res.code === 200 && Array.isArray(res.data)) {
| const list = res.data
| xAxis1.value[0].data = list.map((d) => d.date)
| lineSeries.value[0].data = list.map((d) => Number(d.outCount) || 0)
| lineSeries.value[1].data = list.map((d) => Number(d.inCount) || 0)
| }
| })
| .catch((err) => {
| console.error('获取产品出入库分析失败:', err)
| })
| }
|
| const handleFilterChange = () => {
| fetchData()
| }
|
| onMounted(() => {
| fetchData()
| })
| </script>
|
| <style scoped>
| .main-panel {
| display: flex;
| flex-direction: column;
| gap: 20px;
| }
|
| .filters-row {
| display: flex;
| justify-content: flex-end;
| align-items: center;
| gap: 12px;
| margin-bottom: 10px;
| }
|
| .panel-item-customers {
| border: 1px solid #1a58b0;
| padding: 18px;
| width: 100%;
| height: 428px;
| }
| </style>
|
|