static.vue 3.79 KB
<template>
  <div class="template-box content_div_main noBackGround">
    <el-form :inline="true" class="search-form" size="small">
      <el-form-item label="社区选择:">
        <el-select v-model="mallId" placeholder="请选择">
         <el-option
           v-for="item in mallData"
          :key="item.unid" :value="item.id" :label="item.name"
         ></el-option>
         </el-select>
      </el-form-item>
       <el-form-item label="查询时间:">
          <el-date-picker
               v-model="datatime"
               type="date"
               value-format="yyyy-MM-dd"
               placeholder="选择日期"
               :picker-options="pickerOptions">
             </el-date-picker>
      </el-form-item>
       <el-form-item>
        <el-button  class="search-btn" @click="searchFaceCheck" icon="el-icon-search">查询</el-button>
        <!-- <el-button  class="search-btn ml10"  @click="exportCluster()" icon="el-icon-upload">导出</el-button> -->
      </el-form-item>
    </el-form>
    <div class="chartBox">
      <div class="radioBox" style="left: 140px;">
          <el-radio-group v-model="radioVal" size="small">
            <el-radio-button label="trend7">天汇总</el-radio-button>
            <el-radio-button label="trend15">小时级</el-radio-button>
            <el-radio-button label="trend30">分钟级</el-radio-button>
          </el-radio-group>
        </div>
      <chart chartId="chart2" :chartType="type" :chartData="chartData2" class="chart"></chart>
    </div>

  </div>
</template>

<script>
  import chart from "../public/chart.vue"
export default {
   data() {
      return {
        type:"AreaLine",
        pickerOptions:{
          disabledDate(time) {
            return time.getTime() > Date.now();
          },
        },
        datatime:this.common.formatDateFun(new Date(), "yyyy-MM-dd"),
        datas:{},
        chartData2:{},
        radioVal:"trend15",
        mallData:[],
        mallId:'',
        accountId:localStorage.getItem("accountId")
      }
  },
  watch:{
    radioVal(newVal,oldVal){
      this.radioChange(this.datas)
    }
  },
  components:{
    chart
  },
  methods: {
    searchFaceCheck(){
      this.initChart();
    },
    getMallList(){
          this.axios.get(this.API.url + "/malls",{
            params:{
              accountId:this.accountId,
              status:1
            }
          }).then((response)=> {
             this.mallData = response.data.data;
             if(response.data.data.length>0){
               this.mallId=response.data.data[0].id
             }
            this.initChart();
          });

    },
    initChart(){
      this.axios.get(this.API.url+"/report/basics/day/mall",{
        params:{
          orgIds: this.mallId,
          date: this.datatime,
          chartIds: '283,284,285',
          option: "TAB_CHART"
        }
      }).then((res)=>{
        this.datas=res.data.data;
         this.radioChange(this.datas);
      })
    },
    radioChange(res){
      switch (this.radioVal){
        case "trend7":
        this.type="Bar";
          this.chartData2=res.body.detailData;
          break;
        case "trend15":
        this.type="AreaLine";
          this.chartData2=res.body.trafficHour;
          break;
        case "trend30":
        this.type="AreaLine";
          this.chartData2=res.body.traffic10Min;
          this.chartData2.otherConf={
            isYear:true
          }
          break;
        default:
          break;
      }
      if(this.chartData2.otherConf){
         this.chartData2.otherConf._color=["#4BBEFF", "#87D14B", "#FFC62E", "#FF9631"]
      }else{
         this.chartData2.otherConf={
           _color:["#4BBEFF", "#87D14B", "#FFC62E", "#FF9631"]
         }
      }


    }
  },
  mounted() {
    this.getMallList();
  }
 }
</script>
<style  scoped>
  .chart{
    height: 500px;
  }
</style>