analysisPage.vue 6.43 KB
Newer Older
qzhxx's avatar
qzhxx committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240
<template>
  <div class="analysisPage H100">
    <div class="form_box">
      <el-form :inline="true"  class="search-form">
        <el-form-item>
          <span>查询条件</span>
        </el-form-item>
        <el-form-item>
          <el-date-picker style="margin: 10px 0px 0px;"
            v-model="value7"
            type="daterange"
            @change="getProcessDateItem"
            range-separator="至"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
            value-format="yyyy-MM-dd">
          </el-date-picker>
        </el-form-item>
        <el-form-item class="r-float">
          <el-button size="mini" type="primary" @click="onSearchs()">查询</el-button>
          <el-button size="mini" :type="primary1"   @click="onSearch('year')"></el-button>
          <el-button size="mini" :type="primary2"   @click="onSearch('month')"></el-button>
          <el-button size="mini" :type="primary3"   @click="onSearch('day')"></el-button>
        </el-form-item>
      </el-form>
    </div>
    <div id="myChart" ></div>
  </div>
</template>

<script>
  import echarts from 'echarts'
  export default {
    data() {
      return {
        value7: '',
        primary1:'primary',
        primary2:'',
        primary3:'',
        series:{},
        dateType:[],
        typeName:[],
        startDate: '',
        endDate: '',
        statisticsType: '',
        timeType: '',
      }
    },
    computed: {},
    mounted() {
      this.onSearch('year');
    },
    components: {},
    methods: {
      getProcessDateItem(val){
        if(val){
          if(val.length !== 0){
            this.startDate = val[0];
            this.endDate = val[1];}
        }else{
          this.startDate = '';
          this.endDate = '';
        }
      },
      onSearchs(){
        this.onSearch(this.statisticsType);
      },
      initGenderChart(){
        let myChart = echarts.init(document.getElementById('myChart'));
        const option= {
          title: {
            text: '页面访问量统计'
          },
          grid: {
            bottom: 80
          },
          // tooltip: {
          //   trigger: 'axis'
          // },
          tooltip : {
            trigger: 'axis',
          },
          legend: {
            top: 5,
            // data: ['业务办理助手','网点服务地图','热门产品','热门活动'],
            data: this.typeName,
          },
          xAxis: {
            type: 'category',
            boundaryGap: false,
            data: this.dateType,
            name: '日期('+this.timeType+')',
            minInterval: 1,
            axisTick: {
              show: false
            },
          },
          yAxis: {
            type: 'value',
            name: '访问量:',
            minInterval: 1,
            axisTick: {
              show: false
            },
          },
          dataZoom: [
            {
              type: 'slider',//图表下方的伸缩条
              show : true,  //是否显示
              realtime : true,  //
              start : 0,  //伸缩条开始位置(1-100),可以随时更改
              end : 100,  //伸缩条结束位置(1-100),可以随时更改
            },
          ],
          series: [{
            // name:'业务办理助手',
            name:this.typeName[0],
            data: this.series[0].data,
            type: 'line',
            smooth: true,
            color: '#E6A23C',
            areaStyle: {
              color: '#E6A23C',
            }
          },{
            // name:'网点服务地图',
            name:this.typeName[1],
            data: this.series[1].data,
            type: 'line',
            smooth: true,
            color: '#aaC7E2',
            areaStyle: {
              color: '#aaC7E2',
            }
          },{
            // name:'热门产品',
            name:this.typeName[2],
            data: this.series[2].data,
            type: 'line',
            smooth: true,
            color: '#67C23A',
            areaStyle: {
              color: '#67C23A',
            }
          },{
            // name:'热门活动',
            name:this.typeName[3],
            data: this.series[3].data,
            type: 'line',
            smooth: true,
            color: '#dd5861',
            areaStyle: {
              color: '#dd5861',
            }
          }]
        };
        myChart.setOption(option);
      },
      onSearch(statisticsType){
        if(statisticsType == 'year'){
          this.primary1='primary';
          this.primary2='';
          this.primary3='';
        }else if(statisticsType == 'month') {
          this.primary2='primary';
          this.primary1='';
          this.primary3='';
        }else{
          this.primary3='primary';
          this.primary1='';
          this.primary2='';
        }

        let vm = this;
        vm.statisticsType = statisticsType;
        vm.timeType = vm.statisticsType == 'year'? '年':(vm.statisticsType == 'month'? '月':'日');
        let param ={
          startDate:vm.startDate,
          endDate:vm.endDate,
          statisticsType: vm.statisticsType,}
        vm.$https({
          url : "pageViews/statisticsPageViews",
          method: 'get',
          authType: this.backToken
        },param).then((res)=>{
          let data = res.data;
          vm.typeName =data.legend.data;
          vm.series = data.series;
          vm.dateType = data.xAxis.data;
          this.initGenderChart();
        }).catch(function(err){
          console.log(err);
        })
      },
    }

  }
</script>

<style lang="less">
  @import '../../style/common';
  .analysisPage{
    .form_box{
      padding: 15px 20px;
      min-width: 460px;
      .search-form{
        padding: 0px 20%;
        min-width: 900px;
        .el-date-editor.el-input,
        .el-date-editor.el-input__inner,
        .el-input--mini .el-input__inner{
          width: 230px!important;
        }
        .el-form-item .el-form-item__content .el-date-editor.el-range-editor.el-input__inner.el-date-editor--daterange{
          margin: 4px 0px 0px!important;
        }
        .el-date-editor .el-range-input{
          width: 100%;
        }
        .el-range-separator{
          width: 30px;
          line-height: 25px;
        }
        .el-date-editor .el-range__icon,.el-date-editor .el-range__close-icon{
          line-height: 25px;
        }
      }
    }
    #myChart{
      width: 100%;
      height: 500px;
      canvas{
        width: 100% !important;
      }
    }
  }



</style>