Authored by OF1706

shop report echart

1 <template> 1 <template>
2 <div class="layout-grey"> 2 <div class="layout-grey">
3 <layout-body> 3 <layout-body>
4 - <layout-filter> 4 +
  5 + <div class="box">
  6 + <div class="box-title" style="marginTop: 20px;">
  7 + 店铺看板
  8 + </div>
  9 + <layout-filter class="box-filter">
5 <filter-item label="时间"> 10 <filter-item label="时间">
6 <date-slot v-model="dateRange"> 11 <date-slot v-model="dateRange">
7 </date-slot> 12 </date-slot>
@@ -14,10 +19,6 @@ @@ -14,10 +19,6 @@
14 <span class="notice">*仅支持导出历史数据,时间跨度不得超过30天</span> 19 <span class="notice">*仅支持导出历史数据,时间跨度不得超过30天</span>
15 </filter-item> 20 </filter-item>
16 </layout-filter> 21 </layout-filter>
17 - <div class="box">  
18 - <div class="box-title" style="marginTop: 20px;">  
19 - 店铺看板  
20 - </div>  
21 <Row style="marginTop: 20px; marginBottom: 30px;"> 22 <Row style="marginTop: 20px; marginBottom: 30px;">
22 <Col span="6"> 23 <Col span="6">
23 <div class="box-item green" > 24 <div class="box-item green" >
@@ -62,6 +63,11 @@ @@ -62,6 +63,11 @@
62 </Col> 63 </Col>
63 </Row> 64 </Row>
64 </div> 65 </div>
  66 +
  67 + <div class="box" style="marginTop: 50px;">
  68 + <div class="box-title" style="marginTop: 20px;">
  69 + 最近30天运营趋势
  70 + </div>
65 <layout-tab> 71 <layout-tab>
66 <div class="tabs-col"> 72 <div class="tabs-col">
67 <Tabs :animated="false" size="small" v-model="curTarget"> 73 <Tabs :animated="false" size="small" v-model="curTarget">
@@ -71,6 +77,8 @@ @@ -71,6 +77,8 @@
71 </Tabs> 77 </Tabs>
72 </div> 78 </div>
73 </layout-tab> 79 </layout-tab>
  80 + </div>
  81 +
74 </layout-body> 82 </layout-body>
75 </div> 83 </div>
76 </template> 84 </template>
@@ -110,28 +118,21 @@ @@ -110,28 +118,21 @@
110 this.endDate = Array.isArray(newDate) ? newDate[1] : newDate; 118 this.endDate = Array.isArray(newDate) ? newDate[1] : newDate;
111 this.day = this.beginDate === this.endDate === this.today ? '' : this.beginDate; 119 this.day = this.beginDate === this.endDate === this.today ? '' : this.beginDate;
112 this.curTarget = 'uv'; 120 this.curTarget = 'uv';
  121 + this.getDataFlag = true;
113 122
114 this.getOverviewData(); 123 this.getOverviewData();
115 124
116 -  
117 -// if (this.beginDate === this.endDate) {  
118 - this.getDataFlag = true; 125 + if (this.endDate !== this.today) {
119 this.getOverviewTrend(); 126 this.getOverviewTrend();
120 -// } 127 + }
121 }, 128 },
122 curTarget(value) { 129 curTarget(value) {
123 130
124 this.curTarget = value; 131 this.curTarget = value;
125 132
126 - if (this.getDataFlag) {  
127 - return;  
128 - } 133 + this.getOverviewTrend(this.curTarget);
129 134
130 -// if (this.beginDate === this.endDate) {  
131 - this.getOverviewTrend();  
132 -// } else {  
133 -// this.setOverviewParamsRank();  
134 -// } 135 + return value;
135 } 136 }
136 }, 137 },
137 mounted() { 138 mounted() {
@@ -140,28 +141,7 @@ @@ -140,28 +141,7 @@
140 methods: { 141 methods: {
141 loadData() { 142 loadData() {
142 this.getOverviewData(); 143 this.getOverviewData();
143 -  
144 -// if (this.beginDate === this.endDate) {  
145 this.getOverviewTrend(); 144 this.getOverviewTrend();
146 -// }  
147 - },  
148 - setOverviewParams() {  
149 -  
150 - // 日期为一天的echart opt  
151 - this.getDataFlag = false;  
152 -  
153 - this.overviewParams = {  
154 - title: '',  
155 - color: '#000',  
156 - legend: [this.beginDate, this.endDate],  
157 - xAxis: this.overviewChartData.xAxis,  
158 - yAxis: [''],  
159 - min: _.min([_.min(this.overviewChartData[this.curTarget][0]), _.min(this.overviewChartData[this.curTarget][1])]),  
160 - series: [  
161 - {name: this.beginDate, data: this.overviewChartData[this.curTarget][0]},  
162 - {name: this.endDate, data: this.overviewChartData[this.curTarget][1]}  
163 - ]  
164 - };  
165 }, 145 },
166 setOverviewParamsRank() { 146 setOverviewParamsRank() {
167 147
@@ -174,41 +154,22 @@ @@ -174,41 +154,22 @@
174 yAxis: [''], 154 yAxis: [''],
175 min: _.min(this.overviewChartData[this.curTarget]), 155 min: _.min(this.overviewChartData[this.curTarget]),
176 series: [ 156 series: [
177 - {name: _.find(this.targetList, {name: this.curTarget}).value, data: this.overviewChartData[this.curTarget]} 157 + {
  158 + name: _.find(this.targetList, {name: this.curTarget}).value,
  159 + data: this.overviewChartData[this.curTarget]
  160 + }
178 ] 161 ]
179 }; 162 };
180 }, 163 },
181 getOverviewTrend() { 164 getOverviewTrend() {
  165 +
182 this.goodService.getOverviewTrend({ 166 this.goodService.getOverviewTrend({
183 type: this.curTarget, 167 type: this.curTarget,
184 - begin: this.beginDate, 168 + begin: moment(this.endDate).subtract(30, 'days').format('YYYY-MM-DD'),
185 end: this.endDate, 169 end: this.endDate,
186 platform: '1,2' 170 platform: '1,2'
187 }).then(ret => { 171 }).then(ret => {
188 172
189 - if (this.beginDate === this.endDate) {  
190 - let result = _.castArray(ret.data);  
191 -  
192 - let item01 = [],  
193 - item02 = [];  
194 -  
195 - _.forEach(result[0], it=>{  
196 - item01.push(it);  
197 - });  
198 - _.forEach(result[1], it=>{  
199 - item02.push(it);  
200 - });  
201 - this.overviewChartData.xAxis = _.map(_.flatten(item01), 'hour');  
202 - this.overviewChartData.uv = [_.map(_.flatten(item01), 'value'), _.map(_.flatten(item02), 'value')];  
203 - this.overviewChartData.pv = [_.map(_.flatten(item01), 'value'), _.map(_.flatten(item02), 'value')];  
204 - this.overviewChartData.orderCount = [_.map(_.flatten(item01), 'value'), _.map(_.flatten(item02), 'value')];  
205 - this.overviewChartData.orderAmount = [_.map(_.flatten(item01), 'value'), _.map(_.flatten(item02), 'value')];  
206 - console.log('进错没有')  
207 - this.setOverviewParams();  
208 -  
209 - } else {  
210 -  
211 - console.log('进来了,大王');  
212 let data = ret.data; 173 let data = ret.data;
213 174
214 let sum = [], 175 let sum = [],
@@ -230,8 +191,6 @@ @@ -230,8 +191,6 @@
230 this.overviewChartData.orderAmount = sum; 191 this.overviewChartData.orderAmount = sum;
231 192
232 this.setOverviewParamsRank(); 193 this.setOverviewParamsRank();
233 - }  
234 -  
235 }); 194 });
236 }, 195 },
237 getOverviewData() { 196 getOverviewData() {
@@ -260,8 +219,6 @@ @@ -260,8 +219,6 @@
260 this.overviewChartData.orderCount = _.get(ret, 'orderCount'); 219 this.overviewChartData.orderCount = _.get(ret, 'orderCount');
261 this.overviewChartData.orderAmount = _.get(ret, 'orderAmount'); 220 this.overviewChartData.orderAmount = _.get(ret, 'orderAmount');
262 this.overviewChartData.xAxis = _.map(formatData, 'hour'); 221 this.overviewChartData.xAxis = _.map(formatData, 'hour');
263 -  
264 -// this.setOverviewParamsRank();  
265 } 222 }
266 }); 223 });
267 }, 224 },
@@ -419,5 +376,11 @@ @@ -419,5 +376,11 @@
419 top: 0; 376 top: 0;
420 } 377 }
421 } 378 }
  379 +
  380 + .box-filter {
  381 + .ivu-date-picker {
  382 + margin-left: 0;
  383 + }
  384 + }
422 </style> 385 </style>
423 386