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>  
5 - <filter-item label="时间">  
6 - <date-slot v-model="dateRange">  
7 - </date-slot>  
8 - </filter-item>  
9 - <filter-item label="快速查询">  
10 - <radio-day v-model="day" class="radio-day"></radio-day>  
11 - </filter-item>  
12 - <filter-item>  
13 - <Button type="primary" @click="exportFile">导出</Button>  
14 - <span class="notice">*仅支持导出历史数据,时间跨度不得超过30天</span>  
15 - </filter-item>  
16 - </layout-filter> 4 +
17 <div class="box"> 5 <div class="box">
18 <div class="box-title" style="marginTop: 20px;"> 6 <div class="box-title" style="marginTop: 20px;">
19 店铺看板 7 店铺看板
20 </div> 8 </div>
  9 + <layout-filter class="box-filter">
  10 + <filter-item label="时间">
  11 + <date-slot v-model="dateRange">
  12 + </date-slot>
  13 + </filter-item>
  14 + <filter-item label="快速查询">
  15 + <radio-day v-model="day" class="radio-day"></radio-day>
  16 + </filter-item>
  17 + <filter-item>
  18 + <Button type="primary" @click="exportFile">导出</Button>
  19 + <span class="notice">*仅支持导出历史数据,时间跨度不得超过30天</span>
  20 + </filter-item>
  21 + </layout-filter>
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,15 +63,22 @@ @@ -62,15 +63,22 @@
62 </Col> 63 </Col>
63 </Row> 64 </Row>
64 </div> 65 </div>
65 - <layout-tab>  
66 - <div class="tabs-col">  
67 - <Tabs :animated="false" size="small" v-model="curTarget">  
68 - <Tab-pane v-for="item in targetList" :label="item.label" :key="item.name" :name="item.name">  
69 - </Tab-pane>  
70 - <EChart :className="[overviewName]" :echartParams="overviewParams"></EChart>  
71 - </Tabs> 66 +
  67 + <div class="box" style="marginTop: 50px;">
  68 + <div class="box-title" style="marginTop: 20px;">
  69 + 最近30天运营趋势
72 </div> 70 </div>
73 - </layout-tab> 71 + <layout-tab>
  72 + <div class="tabs-col">
  73 + <Tabs :animated="false" size="small" v-model="curTarget">
  74 + <Tab-pane v-for="item in targetList" :label="item.label" :key="item.name" :name="item.name">
  75 + </Tab-pane>
  76 + <EChart :className="[overviewName]" :echartParams="overviewParams"></EChart>
  77 + </Tabs>
  78 + </div>
  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();  
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 - }; 144 + this.getOverviewTrend();
165 }, 145 },
166 setOverviewParamsRank() { 146 setOverviewParamsRank() {
167 147
@@ -174,64 +154,43 @@ @@ -174,64 +154,43 @@
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 = []; 173 + let data = ret.data;
194 174
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(); 175 + let sum = [],
  176 + name = [];
208 177
209 - } else { 178 + _.forEach(data, function(value, key) {
210 179
211 - console.log('进来了,大王');  
212 - let data = ret.data; 180 + sum.push(
  181 + _.sum(_.map(value, 'value'))
  182 + );
  183 + name.push(key);
213 184
214 - let sum = [],  
215 - name = []; 185 + });
216 186
217 - _.forEach(data, function(value, key) {  
218 -  
219 - sum.push(  
220 - _.sum(_.map(value, 'value'))  
221 - );  
222 - name.push(key);  
223 -  
224 - });  
225 -  
226 - this.overviewChartData.xAxis = name;  
227 - this.overviewChartData.uv = sum;  
228 - this.overviewChartData.pv = sum;  
229 - this.overviewChartData.orderCount = sum;  
230 - this.overviewChartData.orderAmount = sum;  
231 -  
232 - this.setOverviewParamsRank();  
233 - } 187 + this.overviewChartData.xAxis = name;
  188 + this.overviewChartData.uv = sum;
  189 + this.overviewChartData.pv = sum;
  190 + this.overviewChartData.orderCount = sum;
  191 + this.overviewChartData.orderAmount = sum;
234 192
  193 + this.setOverviewParamsRank();
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