浏览代码

feat:价格趋势需求更改

zhangxin 1 月之前
父节点
当前提交
1d5c118271

+ 280 - 0
pages/clue/components/trend.vue

@@ -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>

+ 3 - 154
pages/clue/mixins/clue.js

@@ -135,66 +135,7 @@ export default {
135 135
 				titleId: "",
136 136
 				videoId: "",
137 137
 			},
138
-			trendModal: false,
139
-			chartData:{},
140
-			color:[],
141
-			opts: {
142
-				color: this.color,
143
-				padding: [20, 10, 20, 0],
144
-				dataLabel: true,
145
-				dataPointShape: true,
146
-				enableScroll: true,
147
-				
148
-				xAxis: {
149
-					disableGrid: true,
150
-					scrollShow: true,
151
-					itemCount: 10,
152
-					rotateLabel: true,
153
-					rotateAngle: 45,
154
-				},
155
-				yAxis: {
156
-					gridType: "dash",
157
-					dashLength: 7,
158
-				},
159
-				legend: {
160
-					show: false,
161
-					type: 'scroll',
162
-					orient: 'horizontal',
163
-					pageSize: 3,
164
-					pageIconSize: 12,
165
-					pageIconColor: '#666',
166
-					pageIconInactiveColor: '#ccc',
167
-					pageTextStyle: {
168
-						color: '#666',
169
-						fontSize: 12
170
-					},
171
-					bottom: 0
172
-				},
173
-				extra: {
174
-					line: {
175
-						type: "curve",
176
-						width: 3,
177
-						activeType: "hollow",
178
-						linearType: "custom",
179
-						onShadow: true,
180
-						animation: "horizontal"
181
-					},
182
-					tooltip:{
183
-						legendShow: true,
184
-						bgOpacity: 0.6,
185
-					}
186
-				}
187
-			},
188
-			model: "",
189
-			maxPrice: [],
190
-			minPrice: [],
191
-			chartShow: false,
192
-			tableData: [],
193
-			date:'',
194
-			columns: [
195
-				{ label: '型号', prop: 'model'},
196
-				{ label: '价格(元)', prop: 'price' },
197
-			],
138
+			
198 139
 		}
199 140
 	},
200 141
 	onPullDownRefresh() {
@@ -221,101 +162,9 @@ export default {
221 162
 	// },
222 163
 		methods: {
223 164
 			handleTrend() {
224
-				this.trendModal = true;
225
-			},
226
-			handleTrendConfirm() {
227
-				this.model = ""
228
-				this.date = ""
229
-				this.tableData = []
230
-				this.chartShow = false
231
-				this.trendModal = false;
232
-			},
233
-			searchTrend(val) {
234
-				if (val !== ''){
235
-					uni.$u.api.inquiryChart({
236
-						model: val,
237
-					}).then(res => {
238
-						if(res.data.length == 0){
239
-							uni.$u.toast("暂无数据")
240
-							this.minPrice = []
241
-							this.maxPrice = []
242
-							this.chartShow = false
243
-							return
244
-						}
245
-						const response = res.data
246
-						this.maxPrice = []
247
-						this.minPrice = []
248
-						this.color = []
249
-						const categories = []
250
-						const dateMap = {}
251
-						response.forEach(item => {
252
-							this.maxPrice.push(item.max)
253
-							this.minPrice.push(item.min)
254
-							item.list.forEach(i => {
255
-								if (!dateMap[i.recycleTime]) {
256
-									dateMap[i.recycleTime] = true
257
-									categories.push(i.recycleTime)
258
-								}
259
-							})
260
-						})
261
-						const series = response.map((item) => {
262
-							const color = this.getRandomColor()
263
-							this.color.push(color)
264
-							const data = categories.map(date => {
265
-								const itemData = item.list.find(i => i.recycleTime === date)
266
-								return itemData ? itemData.price : null
267
-							})
268
-							return {
269
-								name: item.model,
270
-								data: data,
271
-								setShadow: [
272
-									3,
273
-									8,
274
-									15,
275
-									color
276
-								],
277
-							}
278
-						})
279
-						this.opts.color = this.color
280
-						const chartData = {
281
-							categories: categories,
282
-							series: series
283
-						}
284
-						this.chartData = JSON.parse(JSON.stringify(chartData))
285
-						this.chartShow = true
286
-					}).catch((err) => {
287
-						uni.$u.toast(err)
288
-					})
289
-				}
290
-			},
291
-			handleChartClick(event) {
292
-				console.log(event);
293
-				const  index  = event.currentIndex.index;
294
-				// 获取点击的日期
295
-				const date = this.chartData.categories[index];
296
-				this.date = date;
297
-				
298
-				// 构建该日期的所有型号价格数据
299
-				const tableData = [];
300
-				this.chartData.series.forEach(series => {
301
-					const price = series.data[index];
302
-					if (price !== null) {
303
-						tableData.push({
304
-							model: series.name,
305
-							price: price
306
-						});
307
-					}
308
-				});
309
-				this.tableData = tableData;
310
-			},
311
-			getRandomColor(){
312
-				var letters = '0123456789ABCDEF';
313
-				var color = '#';
314
-				for (var i = 0; i < 6; i++) {
315
-					color += letters[Math.floor(Math.random() * 16)];
316
-				}
317
-				return color;
165
+				this.$refs.trendRef.openTrendModal()
318 166
 			},
167
+			
319 168
 			handleAddClue() {
320 169
 				uni.navigateTo({
321 170
 					url: "/pages/addClue/index"

+ 0 - 6
pages/clue/scss/clue.scss

@@ -107,9 +107,3 @@
107 107
 		padding: 15px;
108 108
 	}
109 109
 }
110
-.trend_modal{
111
-	width:100%;
112
-	display: flex;
113
-	flex-direction: column;
114
-	gap: 20rpx;
115
-}

+ 4 - 16
pages/privateClue/index.vue

@@ -48,20 +48,8 @@
48 48
 			groupChild="clueTagDataList" label-key="name" value-key="id" placeholder="请选择线索标签"
49 49
 			v-model="queryParams.allTagList" multiple clearable ref="clueTag"
50 50
 			@confirm="handleClueTagConfirm"></group-select>
51
-		<u-modal :show="trendModal" title="价格趋势" @confirm="handleTrendConfirm" confirmText="关闭弹窗">
52
-			<view class="trend_modal">
53
-				<u-search placeholder="请输入型号" v-model="model" @blur="searchTrend" @custom="searchTrend"></u-search>
54
-				<view class="charts_box" v-if="chartShow">
55
-					<u--text type="primary" :text="`最大价格:${Math.max(...maxPrice)}元`"></u--text>
56
-					<u--text type="warning" :text="`最小价格:${Math.min(...minPrice)}元`"></u--text>
57
-					<qiun-data-charts type="line" :chartData="chartData" canvasId="trendChart" :opts="opts" :ontouch="true" tooltipFormat="tooltipFormatPrice"
58
-						width="700rpx" height="500rpx" backgroundColor="#ffffff" @getIndex="handleChartClick" />
59
-				</view>
60
-				<u--text v-if="tableData.length > 0" :text="'日期:' + date"></u--text>
61
-				<Table ref="customTable" v-if="tableData.length > 0" :tableData="tableData" height="100px" :columns="columns" stripe></Table>
62
-			</view>
63
-		</u-modal>
64
-			
51
+		
52
+		<trend ref="trendRef"></trend>
65 53
 		<view class="suspension_button trend" @click="handleTrend">
66 54
 			趋势
67 55
 		</view>
@@ -77,7 +65,7 @@
77 65
 	import post from "@/pages/clue/post/index.vue";
78 66
 	import sort from "@/pages/clue/components/sort.vue";
79 67
 	import filterQuery from "@/pages/clue/components/filterQuery.vue";
80
-	import Table from '@/components/custom-table/index.vue'
68
+	import trend from '@/pages/clue/components/trend.vue'
81 69
 	export default {
82 70
 		onPullDownRefresh() {
83 71
 			uni.stopPullDownRefresh();
@@ -87,7 +75,7 @@
87 75
 			post,
88 76
 			sort,
89 77
 			filterQuery,
90
-			Table,
78
+			trend,
91 79
 		},
92 80
 		mixins: [clue],
93 81
 		onLoad(option) {

+ 4 - 16
pages/publicClue/index.vue

@@ -48,20 +48,8 @@
48 48
 			groupChild="clueTagDataList" label-key="name" value-key="id" placeholder="请选择线索标签"
49 49
 			v-model="queryParams.allTagList" multiple clearable ref="clueTag"
50 50
 			@confirm="handleClueTagConfirm"></group-select>
51
-		<u-modal :show="trendModal" title="价格趋势" @confirm="handleTrendConfirm" confirmText="关闭弹窗">
52
-			<view class="trend_modal">
53
-				<u-search placeholder="请输入型号" v-model="model" @blur="searchTrend" @custom="searchTrend"></u-search>
54
-				<view class="charts_box" v-if="chartShow">
55
-					<u--text type="primary" :text="`最大价格:${Math.max(...maxPrice)}元`"></u--text>
56
-					<u--text type="warning" :text="`最小价格:${Math.min(...minPrice)}元`"></u--text>
57
-					<qiun-data-charts type="line" :chartData="chartData" canvasId="trendChart" :opts="opts" :ontouch="true" tooltipFormat="tooltipFormatPrice"
58
-						width="700rpx" height="500rpx" backgroundColor="#ffffff" @getIndex="handleChartClick" />
59
-				</view>
60
-				<u--text v-if="tableData.length > 0" :text="'日期:' + date"></u--text>
61
-				<Table ref="customTable" v-if="tableData.length > 0" :tableData="tableData" height="100px" :columns="columns" stripe></Table>
62
-			</view>
63
-		</u-modal>
64
-		
51
+
52
+		<trend ref="trendRef"></trend>
65 53
 		<view class="suspension_button trend" @click="handleTrend">
66 54
 			趋势
67 55
 		</view>
@@ -77,7 +65,7 @@
77 65
 	import post from "@/pages/clue/post/index.vue";
78 66
 	import sort from "@/pages/clue/components/sort.vue";
79 67
 	import filterQuery from "@/pages/clue/components/filterQuery.vue";
80
-	import Table from '@/components/custom-table/index.vue'
68
+	import trend from '@/pages/clue/components/trend.vue'
81 69
 	export default {
82 70
 		onPullDownRefresh() {
83 71
 			uni.stopPullDownRefresh();
@@ -87,7 +75,7 @@
87 75
 			post,
88 76
 			sort,
89 77
 			filterQuery,
90
-			Table,
78
+			trend,
91 79
 		},
92 80
 		mixins: [clue],
93 81
 		onLoad() {

+ 5 - 2
pages/wareHouse/components/edit.vue

@@ -26,7 +26,7 @@
26 26
                                 @click="handlePasteRecognition(recognitionContent)"></u-button>
27 27
                         </view>
28 28
                     </u-form-item>
29
-                    <u-form-item :label="'商品图片(' + (formData.goodPicFileList.length || 0) + '张)'" required  borderBottom>
29
+                    <u-form-item :label="'商品图片(' + (formData.goodPicFileList.length || 0) + '张)'" required prop="goodPicFileList" borderBottom>
30 30
                         <view class="imgs_scroll">
31 31
                             <ImgsRowScroll v-if="formData.goodPicFileList.length > 0" :isShowDeleteIcon="true"
32 32
                                 @deleteImgInfo="getDeleteGoodPicInfo" imgMode="aspectFill" :totalWidth="400"
@@ -57,7 +57,7 @@
57 57
                     <u-form-item label="系列" class="u-form-item-row" borderBottom>
58 58
                         <u--input v-model="formData.series" placeholder="请输入" clearable border="none"></u--input>
59 59
                     </u-form-item>
60
-                    <u-form-item label="型号" class="u-form-item-row" borderBottom>
60
+                    <u-form-item label="型号" required prop="model" class="u-form-item-row" borderBottom>
61 61
                         <u--input v-model="formData.model" placeholder="请输入" clearable border="none"></u--input>
62 62
                     </u-form-item>
63 63
                     <u-form-item label="机芯类型" class="u-form-item-row" borderBottom>
@@ -355,6 +355,9 @@ export default {
355 355
                 dictLabel: [
356 356
                     { required: true, message: '请选择品牌', trigger: ['blur', 'change'] },
357 357
                 ],
358
+                model: [
359
+                    { required: true, message: '请输入型号', trigger: ['blur', 'change'] },
360
+                ],
358 361
                 productCondition: [
359 362
                     { required: true, message: '请选择商品成色', trigger: ['blur', 'change'] },
360 363
                 ],