zhangxin 1 месяц назад
Родитель
Сommit
169db3294f

+ 151 - 37
components/add-inquiry-dialog/index.vue

@@ -1,6 +1,7 @@
1 1
 <template>
2 2
 	<view>
3 3
 		<u-modal :show="showModal" ref="uModal" :title="(editOrAdd === 'add' || editOrAdd === 'receptFormAdd') ? '新增' : '编辑'" :asyncClose="false" showCancelButton @cancel="closeDialog" cancelColor="#909399" :confirmText="'确定'" confirmColor="#2979ff" @confirm="confirm" @close="closeDialog" :closeOnClickOverlay="false">
4
+            <u--text type="info" text="输入型号可查看价格趋势"></u--text>
4 5
             <view class="modal_wrap">
5 6
                 <text @click="handleBrandClick" class="item" :class="info.dictLabel ? 'brand' : 'brand placeholder'">{{ info.dictLabel || '品牌' }}</text>
6 7
                 <text class="divider">|</text>
@@ -19,8 +20,10 @@
19 20
             </view>
20 21
             <u--input v-if="editOrAdd === 'edit'" class="price" placeholder="价格" border="bottom" v-model="info.price" clearable></u--input>
21 22
             <view class="charts_box" v-show="chartShow">
22
-                <qiun-data-charts type="line" :chartData="chartData" canvasId="trendChart" :opts="opts" :ontouch="true"
23
-                    width="700rpx" height="200rpx" backgroundColor="#ffffff" />
23
+                 <u--text type="primary" :text="`最大价格:${Math.max(...maxPrice)}元`"></u--text>
24
+                 <u--text type="warning" :text="`最小价格:${Math.min(...minPrice)}元`"></u--text>
25
+                <qiun-data-charts type="line" :chartData="chartData" canvasId="trendChart" :opts="opts" :ontouch="true" tooltipFormat="tooltipFormatPrice"
26
+                    width="700rpx" height="500rpx" backgroundColor="#ffffff" />
24 27
             </view>
25 28
         </u-modal>
26 29
         <brandList ref="brandListRef" @selectedBrand="handleSelectedBrand"></brandList>
@@ -77,15 +80,14 @@ export default {
77 80
                 ]
78 81
             },
79 82
             chartData:{},
83
+            color:[],
80 84
             opts: {
81
-                color: ["#f9ae3d"],
82
-                padding: [10, 10, 0, 0],
83
-                dataLabel: false,
84
-                dataPointShape: false,
85
+                color: this.color,
86
+                padding: [20, 10, 20, 0],
87
+                dataLabel: true,
88
+                dataPointShape: true,
85 89
                 enableScroll: true,
86
-                legend: {
87
-                    show: false
88
-                },
90
+                
89 91
                 xAxis: {
90 92
                     disableGrid: true,
91 93
                     scrollShow: true,
@@ -97,6 +99,20 @@ export default {
97 99
                     gridType: "dash",
98 100
                     dashLength: 7,
99 101
                 },
102
+                legend: {
103
+                    show: false,
104
+                    type: 'scroll',
105
+                    orient: 'horizontal',
106
+                    pageSize: 3,
107
+                    pageIconSize: 12,
108
+                    pageIconColor: '#666',
109
+                    pageIconInactiveColor: '#ccc',
110
+                    pageTextStyle: {
111
+                        color: '#666',
112
+                        fontSize: 12
113
+                    },
114
+                    bottom: 0
115
+                },
100 116
                 extra: {
101 117
                     line: {
102 118
                         type: "curve",
@@ -105,10 +121,16 @@ export default {
105 121
                         linearType: "custom",
106 122
                         onShadow: true,
107 123
                         animation: "horizontal"
124
+                    },
125
+                    tooltip:{
126
+                        legendShow: true,
127
+                        bgOpacity: 0.6
108 128
                     }
109 129
                 }
110 130
             },
111
-            chartShow: false
131
+            chartShow: false,
132
+            maxPrice: [],
133
+            minPrice: [],
112 134
 		}
113 135
 	},
114 136
 	watch: {
@@ -120,6 +142,125 @@ export default {
120 142
 		}
121 143
 	},
122 144
 	methods: {
145
+        getChartData() {
146
+            uni.$u.api.inquiryChart({
147
+                model: this.info.model,
148
+            }).then(res => {
149
+                if (res.code == 200) {
150
+                    const response = res.data
151
+                    this.maxPrice = []
152
+                    this.minPrice = []
153
+                    // const response = [
154
+                    //     {
155
+                    //         model:'AAA',
156
+                    //         list:[
157
+                    //             {
158
+                    //                 recycleTime: '2023-07-30',
159
+                    //                 price: 300,
160
+                    //             },
161
+                    //             {
162
+                    //                 recycleTime: '2023-07-31',
163
+                    //                 price: 500,
164
+                    //             },
165
+                    //             {
166
+                    //                 recycleTime: '2023-08-01',
167
+                    //                 price: null,
168
+                    //             },
169
+                    //             {
170
+                    //                 recycleTime: '2023-08-02',
171
+                    //                 price: 200,
172
+                    //             },
173
+                    //             {
174
+                    //                 recycleTime: '2023-08-03',
175
+                    //                 price: 300,
176
+                    //             }
177
+                    //         ]
178
+                    //     },
179
+                    //     {
180
+                    //         model:'BBB',
181
+                    //         list:[
182
+                    //             {
183
+                    //                 recycleTime: '2023-08-01',
184
+                    //                 price:400,
185
+                    //             },
186
+                    //             {
187
+                    //                 recycleTime: '2023-08-02',
188
+                    //                 price: 100,
189
+                    //             },
190
+                    //             {
191
+                    //                 recycleTime: '2023-08-03',
192
+                    //                 price: 200,
193
+                    //             }
194
+                    //         ]
195
+                    //     },
196
+                    //     {
197
+                    //         model:'CCC',
198
+                    //         list:[
199
+                    //             {
200
+                    //                 recycleTime: '2023-08-01',
201
+                    //                 price: 500,
202
+                    //             },
203
+                    //             {
204
+                    //                 recycleTime: '2023-08-02',
205
+                    //                 price: 400,
206
+                    //             },
207
+                    //             {
208
+                    //                 recycleTime: '2023-08-03',
209
+                    //                 price: 600,
210
+                    //             }
211
+                    //         ]
212
+                    //     }
213
+                    // ]
214
+                    this.color = []
215
+                    const categories = []
216
+                    const dateMap = {}
217
+                    response.forEach(item => {
218
+                        this.maxPrice.push(item.max)
219
+                        this.minPrice.push(item.min)
220
+                        item.list.forEach(i => {
221
+                            if (!dateMap[i.recycleTime]) {
222
+                                dateMap[i.recycleTime] = true
223
+                                categories.push(i.recycleTime)
224
+                            }
225
+                        })
226
+                    })
227
+                    const series = response.map((item) => {
228
+                        const color = this.getRandomColor()
229
+                        this.color.push(color)
230
+                        const data = categories.map(date => {
231
+                            const itemData = item.list.find(i => i.recycleTime === date)
232
+                            return itemData ? itemData.price : null
233
+                        })
234
+                        return {
235
+                            name: item.model,
236
+                            data: data,
237
+                            setShadow: [
238
+                                3,
239
+                                8,
240
+                                15,
241
+                                color
242
+                            ],
243
+                        }
244
+                    })
245
+                    this.opts.color = this.color
246
+                    const chartData = {
247
+                        categories: categories,
248
+                        series: series
249
+                    }
250
+                    this.chartData = JSON.parse(JSON.stringify(chartData))
251
+                    this.chartShow = true
252
+                }
253
+            })
254
+            
255
+        },
256
+        getRandomColor(){
257
+            var letters = '0123456789ABCDEF';
258
+            var color = '#';
259
+            for (var i = 0; i < 6; i++) {
260
+                color += letters[Math.floor(Math.random() * 16)];
261
+            }
262
+            return color;
263
+        },
123 264
         // 编辑回显
124 265
         initData() {
125 266
             this.$nextTick(()=>{
@@ -241,33 +382,6 @@ export default {
241 382
                 this.getChartData()
242 383
             }
243 384
         },
244
-        getChartData() {
245
-            uni.$u.api.inquiryChart({
246
-                model: this.info.model,
247
-            }).then(res => {
248
-                if (res.code == 200) {
249
-                    const reverseData = res.data.reverse()
250
-                    let data = {
251
-                        categories: reverseData.map(item=>item.recycleTime),
252
-                        series: [
253
-                            {
254
-                                name: this.info.model+'价格',
255
-                                data: reverseData.map(item=>item.price),
256
-                                setShadow: [
257
-                                    3,
258
-                                    8,
259
-                                    15,
260
-                                    "#f9ae3d"
261
-                                ],
262
-                            }
263
-                        ]
264
-                    }
265
-                    this.chartData = JSON.parse(JSON.stringify(data))
266
-                    this.chartShow = true
267
-                }
268
-            })
269
-            
270
-        },
271 385
 	}
272 386
 };
273 387
 </script>

+ 7 - 3
pages/wareHouse/components/edit.vue

@@ -38,8 +38,8 @@
38 38
                     </u-form-item>
39 39
                     <u-form-item label="商品描述(详细的描述让用户更好的了解您的产品)" required prop="desc" borderBottom>
40 40
                         <u--textarea v-model="formData.desc" clearable placeholder="95新 WHZ19219H CHANEL香奈儿链条单肩包
41
-                        21开 牛皮 尺寸25 4 15
42
-                        配件中溯卡" count autoHeight maxlength="250" height="100" confirmType="done"></u--textarea>
41
+21开 牛皮 尺寸25 4 15
42
+配件中溯卡" count autoHeight maxlength="250" :height="150" confirmType="done"></u--textarea>
43 43
                     </u-form-item>
44 44
                     <u-form-item label="来源" prop="origin" borderBottom>
45 45
                         <u--textarea v-model="formData.origin" clearable placeholder="请输入来源" count autoHeight maxlength="250" height="100" confirmType="done"></u--textarea>
@@ -254,7 +254,7 @@
254 254
             </view>
255 255
         </view>
256 256
         <view :class="['btn_group', {'col-2': formData.stockStatus == '1'}]">
257
-            <u-button plain type="primary" @click="submitForm('onlyIn')">{{ formData.stockStatus == '0' ? '待入库' : '仅入库' }}</u-button>
257
+            <u-button plain type="primary" @click="submitForm('onlyIn')">保存</u-button>
258 258
             <u-button type="primary" @click="submitForm('inAndUp')" v-if="formData.stockStatus == '1'">入库并上架</u-button>
259 259
         </view>
260 260
     </view>
@@ -297,6 +297,7 @@ export default {
297 297
                 productCondition: '1',
298 298
                 detailPicFileList: [],//细节图片
299 299
                 // detailVideoFileList:[],
300
+                title:'',
300 301
                 productNo: '',
301 302
                 productAttribute: '1',
302 303
                 stock: 1,
@@ -497,6 +498,9 @@ export default {
497 498
                     this.echoInfoProductAttribute = res.data.productAttribute || '1'
498 499
                     this.echoInfoProductCondition = res.data.productCondition || '1'
499 500
                     this.echoInfoStockStatus = res.data.stockStatus || '0'
501
+                    this.$nextTick(()=>{
502
+                        this.$refs.addForm.resetFields();
503
+                    })
500 504
                 });
501 505
             }
502 506
         })

+ 3 - 0
uni_modules/qiun-data-charts/js_sdk/u-charts/config-ucharts.js

@@ -71,6 +71,9 @@ const cfu = {
71 71
         return series[index].name+':'+series[index].data+'元'
72 72
       }
73 73
     },
74
+	'tooltipFormatPrice':function(item, category, index, opts){
75
+		return item.name + category.substring(2) + ':' + item.data + '元'
76
+    },
74 77
   },
75 78
   //这里演示了自定义您的图表类型的option,可以随意命名,之后在组件上 type="demotype" 后,组件会调用这个花括号里的option,如果组件上还存在opts参数,会将demotype与opts中option合并后渲染图表。
76 79
   "demotype":{

+ 8 - 0
uni_modules/qiun-data-charts/js_sdk/u-charts/u-charts.js

@@ -2785,6 +2785,14 @@ function drawBarToolTipSplitArea(offsetX, opts, config, context, eachSpacing) {
2785 2785
 
2786 2786
 
2787 2787
 function drawToolTip(textList, offset, opts, config, context, eachSpacing, xAxisPoints) {
2788
+  // let newTextList = {
2789
+  //   "text": '价格趋势',
2790
+  //   color: '#e61414ff'
2791
+  // }
2792
+  textList[0].text = textList[0].text.split("/")[0]
2793
+  // textList.push(newTextList)
2794
+  textList = textList.reverse();
2795
+
2788 2796
   var toolTipOption = assign({}, {
2789 2797
     showBox: true,
2790 2798
     showArrow: true,