|
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+<template>
|
|
|
2
|
+ <u-modal :show="trendModal" title="价格趋势" @confirm="closeTrendModal" confirmText="关闭弹窗" height="80%">
|
|
|
3
|
+ <view class="trend_modal">
|
|
|
4
|
+ <u-search placeholder="请输入型号" v-model="model" @blur="searchTrend" @custom="searchTrend"></u-search>
|
|
|
5
|
+ <view class="charts_box" v-if="chartShow">
|
|
|
6
|
+ <u--text type="primary" :text="`最大价格:${Math.max(...maxPrice)}元`"></u--text>
|
|
|
7
|
+ <u--text type="warning" :text="`最小价格:${Math.min(...minPrice)}元`"></u--text>
|
|
|
8
|
+ <qiun-data-charts type="line" :chartData="chartData" canvasId="trendChart" :opts="opts" :ontouch="true"
|
|
|
9
|
+ tooltipFormat="tooltipFormatPrice" width="700rpx" height="500rpx" backgroundColor="#ffffff"
|
|
|
10
|
+ @getIndex="handleChartClick" />
|
|
|
11
|
+ </view>
|
|
|
12
|
+
|
|
|
13
|
+ <!-- <u--text v-if="cardData.length > 0" :text="'日期:' + date"></u--text> -->
|
|
|
14
|
+ <view class="card-container" v-if="cardData.length > 0">
|
|
|
15
|
+ <view class="card-item" v-for="(item, index) in cardData" :key="index">
|
|
|
16
|
+ <view class="card-row">
|
|
|
17
|
+ <span class="card-label">型号:</span>
|
|
|
18
|
+ <span class="card-value">{{ item.model }}</span>
|
|
|
19
|
+ </view>
|
|
|
20
|
+ <view class="card-row">
|
|
|
21
|
+ <span class="card-label">日期:</span>
|
|
|
22
|
+ <span class="card-value">{{ formatTime(item.recycleTime) }}</span>
|
|
|
23
|
+ </view>
|
|
|
24
|
+ <view class="card-row">
|
|
|
25
|
+ <span class="card-label">价格:</span>
|
|
|
26
|
+ <span class="card-value">{{ item.price }}元</span>
|
|
|
27
|
+ </view>
|
|
|
28
|
+ <view class="card-row">
|
|
|
29
|
+ <span class="card-label">回收情况:</span>
|
|
|
30
|
+ <span class="card-value">{{ formatRecycleSituation(item.recycleSituation) }}</span>
|
|
|
31
|
+ </view>
|
|
|
32
|
+ <view class="card-row">
|
|
|
33
|
+ <span class="card-label">备注:</span>
|
|
|
34
|
+ <span class="card-value">{{ item.remark || '-' }}</span>
|
|
|
35
|
+ </view>
|
|
|
36
|
+ </view>
|
|
|
37
|
+ </view>
|
|
|
38
|
+ </view>
|
|
|
39
|
+ </u-modal>
|
|
|
40
|
+</template>
|
|
|
41
|
+
|
|
|
42
|
+<script>
|
|
|
43
|
+import { recycleSituationList } from '@/pages/wareHouse/js/public.js'
|
|
|
44
|
+export default {
|
|
|
45
|
+ name: 'ComponentName',
|
|
|
46
|
+ data() {
|
|
|
47
|
+ return {
|
|
|
48
|
+ trendModal: false,
|
|
|
49
|
+ chartData: {},
|
|
|
50
|
+ color: [],
|
|
|
51
|
+ opts: {
|
|
|
52
|
+ color: this.color,
|
|
|
53
|
+ padding: [20, 10, 20, 0],
|
|
|
54
|
+ dataLabel: true,
|
|
|
55
|
+ dataPointShape: true,
|
|
|
56
|
+ enableScroll: true,
|
|
|
57
|
+
|
|
|
58
|
+ xAxis: {
|
|
|
59
|
+ disableGrid: true,
|
|
|
60
|
+ scrollShow: true,
|
|
|
61
|
+ itemCount: 10,
|
|
|
62
|
+ rotateLabel: true,
|
|
|
63
|
+ rotateAngle: 45,
|
|
|
64
|
+ },
|
|
|
65
|
+ yAxis: {
|
|
|
66
|
+ gridType: "dash",
|
|
|
67
|
+ dashLength: 7,
|
|
|
68
|
+ },
|
|
|
69
|
+ legend: {
|
|
|
70
|
+ show: false,
|
|
|
71
|
+ type: 'scroll',
|
|
|
72
|
+ orient: 'horizontal',
|
|
|
73
|
+ pageSize: 3,
|
|
|
74
|
+ pageIconSize: 12,
|
|
|
75
|
+ pageIconColor: '#666',
|
|
|
76
|
+ pageIconInactiveColor: '#ccc',
|
|
|
77
|
+ pageTextStyle: {
|
|
|
78
|
+ color: '#666',
|
|
|
79
|
+ fontSize: 12
|
|
|
80
|
+ },
|
|
|
81
|
+ bottom: 0
|
|
|
82
|
+ },
|
|
|
83
|
+ extra: {
|
|
|
84
|
+ line: {
|
|
|
85
|
+ type: "curve",
|
|
|
86
|
+ width: 3,
|
|
|
87
|
+ activeType: "hollow",
|
|
|
88
|
+ linearType: "custom",
|
|
|
89
|
+ onShadow: true,
|
|
|
90
|
+ animation: "horizontal"
|
|
|
91
|
+ },
|
|
|
92
|
+ tooltip: {
|
|
|
93
|
+ legendShow: false,
|
|
|
94
|
+ bgOpacity: 0.6,
|
|
|
95
|
+ }
|
|
|
96
|
+ }
|
|
|
97
|
+ },
|
|
|
98
|
+ model: "",
|
|
|
99
|
+ maxPrice: [],
|
|
|
100
|
+ minPrice: [],
|
|
|
101
|
+ chartShow: false,
|
|
|
102
|
+ cardData: [],
|
|
|
103
|
+ date: '',
|
|
|
104
|
+ recycleSituationList: recycleSituationList,
|
|
|
105
|
+ }
|
|
|
106
|
+ },
|
|
|
107
|
+ props: {
|
|
|
108
|
+ },
|
|
|
109
|
+ emits: [],
|
|
|
110
|
+ methods: {
|
|
|
111
|
+ openTrendModal() {
|
|
|
112
|
+ this.trendModal = true;
|
|
|
113
|
+ },
|
|
|
114
|
+ closeTrendModal() {
|
|
|
115
|
+ this.model = ""
|
|
|
116
|
+ this.date = ""
|
|
|
117
|
+ this.cardData = []
|
|
|
118
|
+ this.chartShow = false
|
|
|
119
|
+ this.trendModal = false;
|
|
|
120
|
+ },
|
|
|
121
|
+ searchTrend(val) {
|
|
|
122
|
+ if (val !== '') {
|
|
|
123
|
+ uni.$u.api.inquiryChart({
|
|
|
124
|
+ model: val,
|
|
|
125
|
+ }).then(res => {
|
|
|
126
|
+ if (res.data.length == 0) {
|
|
|
127
|
+ uni.$u.toast("暂无数据")
|
|
|
128
|
+ this.minPrice = []
|
|
|
129
|
+ this.maxPrice = []
|
|
|
130
|
+ this.chartShow = false
|
|
|
131
|
+ return
|
|
|
132
|
+ }
|
|
|
133
|
+ const response = res.data
|
|
|
134
|
+ this.maxPrice = []
|
|
|
135
|
+ this.minPrice = []
|
|
|
136
|
+ this.color = []
|
|
|
137
|
+ const categories = []
|
|
|
138
|
+ const dateMap = {}
|
|
|
139
|
+ response.forEach(item => {
|
|
|
140
|
+ this.maxPrice.push(item.max)
|
|
|
141
|
+ this.minPrice.push(item.min)
|
|
|
142
|
+ item.list.forEach(i => {
|
|
|
143
|
+ i.recycleTime = this.formatTime(i.recycleTime)
|
|
|
144
|
+ if (!dateMap[i.recycleTime]) {
|
|
|
145
|
+ dateMap[i.recycleTime] = true
|
|
|
146
|
+ categories.push(i.recycleTime)
|
|
|
147
|
+ }
|
|
|
148
|
+ })
|
|
|
149
|
+ })
|
|
|
150
|
+ const series = response.map((item) => {
|
|
|
151
|
+ const color = this.getRandomColor()
|
|
|
152
|
+ this.color.push(color)
|
|
|
153
|
+ const data = categories.map(date => {
|
|
|
154
|
+ const itemData = item.list.find(i => this.formatTime(i.recycleTime) == date)
|
|
|
155
|
+ return itemData ? itemData.price : null
|
|
|
156
|
+ })
|
|
|
157
|
+ return {
|
|
|
158
|
+ name: item.model,
|
|
|
159
|
+ data: data,
|
|
|
160
|
+ list: item.list,
|
|
|
161
|
+ setShadow: [
|
|
|
162
|
+ 3,
|
|
|
163
|
+ 8,
|
|
|
164
|
+ 15,
|
|
|
165
|
+ color
|
|
|
166
|
+ ],
|
|
|
167
|
+ }
|
|
|
168
|
+ })
|
|
|
169
|
+ this.opts.color = this.color
|
|
|
170
|
+ const chartData = {
|
|
|
171
|
+ categories: categories,
|
|
|
172
|
+ series: series
|
|
|
173
|
+ }
|
|
|
174
|
+ this.chartData = JSON.parse(JSON.stringify(chartData))
|
|
|
175
|
+ this.cardData = []
|
|
|
176
|
+ this.chartShow = true
|
|
|
177
|
+ }).catch((err) => {
|
|
|
178
|
+ uni.$u.toast(err)
|
|
|
179
|
+ })
|
|
|
180
|
+ }
|
|
|
181
|
+ },
|
|
|
182
|
+ formatTime(date){
|
|
|
183
|
+ return this.$dayjs(date).format('YYYY-MM-DD')
|
|
|
184
|
+ },
|
|
|
185
|
+ formatRecycleSituation(situation) {
|
|
|
186
|
+ const item = this.recycleSituationList.find(i => i.value == situation)
|
|
|
187
|
+ return item ? item.name : '-'
|
|
|
188
|
+ },
|
|
|
189
|
+ handleChartClick(event) {
|
|
|
190
|
+ const index = event.currentIndex.index;
|
|
|
191
|
+ // 获取点击的日期
|
|
|
192
|
+ const date = this.chartData.categories[index];
|
|
|
193
|
+ this.date = date;
|
|
|
194
|
+
|
|
|
195
|
+ // 构建该日期的所有型号价格数据
|
|
|
196
|
+ const cardData = [];
|
|
|
197
|
+ this.chartData.series.forEach(series => {
|
|
|
198
|
+ const price = series.data[index];
|
|
|
199
|
+ if (price !== null) {
|
|
|
200
|
+ // 查找对应日期的完整数据
|
|
|
201
|
+ const itemData = series.list.find(i => i.recycleTime === date);
|
|
|
202
|
+ cardData.push({
|
|
|
203
|
+ model: series.name,
|
|
|
204
|
+ price: price,
|
|
|
205
|
+ recycleSituation: itemData?.recycleSituation || '',
|
|
|
206
|
+ remark: itemData?.remark || ''
|
|
|
207
|
+ });
|
|
|
208
|
+ }
|
|
|
209
|
+ });
|
|
|
210
|
+ this.cardData = cardData;
|
|
|
211
|
+ },
|
|
|
212
|
+ getRandomColor() {
|
|
|
213
|
+ var letters = '0123456789ABCDEF';
|
|
|
214
|
+ var color = '#';
|
|
|
215
|
+ for (var i = 0; i < 6; i++) {
|
|
|
216
|
+ color += letters[Math.floor(Math.random() * 16)];
|
|
|
217
|
+ }
|
|
|
218
|
+ return color;
|
|
|
219
|
+ },
|
|
|
220
|
+ }
|
|
|
221
|
+}
|
|
|
222
|
+</script>
|
|
|
223
|
+
|
|
|
224
|
+<style lang="scss" scoped>
|
|
|
225
|
+.trend_modal {
|
|
|
226
|
+ width: 100%;
|
|
|
227
|
+ display: flex;
|
|
|
228
|
+ flex-direction: column;
|
|
|
229
|
+ gap: 20rpx;
|
|
|
230
|
+}
|
|
|
231
|
+
|
|
|
232
|
+.card-container {
|
|
|
233
|
+ display: flex;
|
|
|
234
|
+ flex-direction: column;
|
|
|
235
|
+ gap: 16rpx;
|
|
|
236
|
+ max-height: 500rpx;
|
|
|
237
|
+ overflow-y: auto;
|
|
|
238
|
+ font-size:26rpx;
|
|
|
239
|
+
|
|
|
240
|
+ &::-webkit-scrollbar {
|
|
|
241
|
+ width: 6rpx;
|
|
|
242
|
+ }
|
|
|
243
|
+
|
|
|
244
|
+ &::-webkit-scrollbar-track {
|
|
|
245
|
+ background: #f1f1f1;
|
|
|
246
|
+ border-radius: 3rpx;
|
|
|
247
|
+ }
|
|
|
248
|
+
|
|
|
249
|
+ &::-webkit-scrollbar-thumb {
|
|
|
250
|
+ background: #c1c1c1;
|
|
|
251
|
+ border-radius: 3rpx;
|
|
|
252
|
+
|
|
|
253
|
+ &:hover {
|
|
|
254
|
+ background: #a8a8a8;
|
|
|
255
|
+ }
|
|
|
256
|
+ }
|
|
|
257
|
+}
|
|
|
258
|
+
|
|
|
259
|
+.card-item {
|
|
|
260
|
+ background-color: #f5f5f5;
|
|
|
261
|
+ border-radius: 8rpx;
|
|
|
262
|
+ padding: 16rpx;
|
|
|
263
|
+ box-shadow: 0 2rpx 4rpx rgba(0, 0, 0, 0.1);
|
|
|
264
|
+}
|
|
|
265
|
+
|
|
|
266
|
+.card-row {
|
|
|
267
|
+ display: flex;
|
|
|
268
|
+ margin-bottom: 10rpx;
|
|
|
269
|
+ align-items: flex-start;
|
|
|
270
|
+
|
|
|
271
|
+ .card-label {
|
|
|
272
|
+ flex-shrink: 0;
|
|
|
273
|
+ }
|
|
|
274
|
+
|
|
|
275
|
+ .card-value {
|
|
|
276
|
+ flex: 1;
|
|
|
277
|
+ word-break: break-all;
|
|
|
278
|
+ }
|
|
|
279
|
+}
|
|
|
280
|
+</style>
|