yz3456
2024-05-13 6a33216302b27ecd657e8e53b12286518a56d1a8
ruoyi-ui/src/views/meeting/statistics.vue
@@ -88,6 +88,20 @@
      <!-- 图表统计 -->
      <el-dialog :title="title2" :visible.sync="open2" width="1500px" @open="openGraph()" append-to-body>
            <div>
                年份
        <el-select v-model="years" id="yearSelect"
                  placeholder="请选择年份" clearable
                   style="width: 240px;
                   height: 35px;
                   border-radius: 16px 16px 16px 16px;
                   opacity: 0.5;" filterable allow-create
                   @change="selectValue">
          <el-option v-for="item in yearOptions"
            :key="item.value" :label="item.label" :value="item.value"/>
        </el-select>
              </div>
        <!-- class="p1" -->
        <div class="p1" id="main1">
          <!-- <h1 style="font-size:21px">每月会议次数统计</h1> -->
@@ -167,6 +181,7 @@
  //在system/note/index.js中导入接口函数  --接好了
  import {listMeeting3,listGraph} from "@/api/meeting/index";
 export default {
  created() {
    this.getList();
@@ -181,8 +196,12 @@
       title: "",
       meetingList: [],
       dataList:[],
       // 饼图数据
       graphID: [],
       // 柱状图数据
       graphDate: [],
       years:undefined,
       yearOptions:[],
       formDat:{
           "title":undefined,
           "familyId":undefined,
@@ -222,29 +241,6 @@
     }
   },
   methods: {
     graphData(){
       this.loading = true;
       listGraph().then(response => {
           this.dataList = response.data
           // console.log(this.graphList,'11111111111')
           let a = {}
           this.dataList.forEach(element=>{
             if(a[element['familyId']]){
               a[element['familyId']] += 1
             }else{
               a[element['familyId']] = 1
             }
           })
           for(let i in a){
             this.graphID.push({'name': i , 'value': a[i]})
           }
           // console.log(this.graphID,'graphIDgraphIDgraphID')
           this.loading = false;
         }
         );
     },
     getList() {
       this.loading = true;
       // console.log(this.queryParams)
@@ -262,6 +258,158 @@
       );
     },
     getTypeOptions(list){
       let years = ['全部']
        let a = {}
       list.forEach(element=>{
         let year = element.createTime.split("-")[0]
         if(a[year]){
         }else{
           a[year] = 1
           years.push(year)
         }
       })
      let yearOptions = []
      for(let i=0;i<years.length;i++){
        yearOptions.push({label: years[i],value: i})
      }
      return yearOptions;
     },
     graphData(){
       this.loading = true;
       listGraph().then(response => {
           this.dataList = response.data
           console.log(this.dataList,'11111111111')
           this.yearOptions = this.getTypeOptions(this.dataList)
           console.log(this.yearOptions,'yearsyearsyearsyears')
           // 家庭号
           let a = {}
           this.dataList.forEach(element=>{
             if(a[element['familyId']]){
               a[element['familyId']] += 1
             }else{
               a[element['familyId']] = 1
             }
           })
           for(let i in a){
            this.graphID.push({'name': i , 'value': a[i]})
           }
           // 每月次数
           let b = {'01': 0,'02': 0,'03': 0,'04': 0,'05': 0,'06': 0,'07': 0,'08': 0,'09': 0,'10': 0,'11': 0,'12': 0}
           this.dataList.forEach(element=>{
             let month = element.createTime.split("-")[1]
             if(b[month]){
               b[month] += 1
             }else{
               b[month] = 1
             }
           })
           let kon =[]
           for(let i in b){
             kon.push({'name': Number(i) , 'value': b[i]})
           }
           this.graphDate = kon.sort((a,b) => a.name - b.name)
           this.loading = false;
         }
         );
     },
    b(list,selectedValue){
      let list2 = []
      let newGraphID = []
      let newGraphDate = []
      list.forEach(element=>{
        let year = element.createTime.split("-")[0]
        if(selectedValue == year){
          list2.push(element)
        }
      })
      if(list2.length !=  0){
        // 家庭号
        let a = {}
        list2.forEach(element=>{
          if(a[element['familyId']]){
            a[element['familyId']] += 1
          }else{
            a[element['familyId']] = 1
          }
        })
        for(let i in a){
          newGraphID.push({'name': i , 'value': a[i]})
        }
        // 每月次数
        let b = {'01': 0,'02': 0,'03': 0,'04': 0,'05': 0,'06': 0,'07': 0,'08': 0,'09': 0,'10': 0,'11': 0,'12': 0}
        list2.forEach(element=>{
          let month = element.createTime.split("-")[1]
          if(b[month]){
            b[month] += 1
          }else{
            b[month] = 1
          }
        })
        let kon =[]
        for(let i in b){
          kon.push({'name': Number(i) , 'value': b[i]})
        }
        newGraphDate = kon.sort((a,b) => a.name - b.name)
      }else{
        list2 = list
        // 家庭号
        let a = {}
        list2.forEach(element=>{
          if(a[element['familyId']]){
            a[element['familyId']] += 1
          }else{
            a[element['familyId']] = 1
          }
        })
        for(let i in a){
          newGraphID.push({'name': i , 'value': a[i]})
        }
        // 每月次数
        let b = {'01': 0,'02': 0,'03': 0,'04': 0,'05': 0,'06': 0,'07': 0,'08': 0,'09': 0,'10': 0,'11': 0,'12': 0}
        list2.forEach(element=>{
          let month = element.createTime.split("-")[1]
          if(b[month]){
            b[month] += 1
          }else{
            b[month] = 1
          }
        })
        let kon =[]
        for(let i in b){
          kon.push({'name': Number(i) , 'value': b[i]})
        }
        newGraphDate = kon.sort((a,b) => a.name - b.name)
      }
      return [newGraphID,newGraphDate];
    },
    selectValue(value){
      let obj = {}
      let year = undefined
      obj= this.yearOptions.find(function(i){
              return i.value ===value
        });
      year = obj.label
      let result = undefined
      result = this.b(this.dataList,year)
      this.graphID = result[0]
      this.graphDate = result[1]
      // console.log(this.graphID)
      // console.log(this.graphDate)
      echarts.dispose(document.getElementById('main1'))
      echarts.dispose(document.getElementById('main2'))
      this.initEcharts()
    },
     openGraph(){
       this.$nextTick(() => {
@@ -278,13 +426,13 @@
                },
                tooltip: {},
                xAxis: {
                    data: ['衬衫', '羊毛衫', '雪纺衫', '裤子', '高跟鞋', '袜子']
                    data: ['1月','2月','3月','4月','5月','6月','7月','8月','9月','10月','11月','12月']
                },
                yAxis: {},
                legend:{},
                series: [{
                    type: 'bar',
                    data: [5, 20, 36, 10, 10, 20]
                    data: this.graphDate.map(x => x.value)
                }]
            };
            myChart1.setOption(option1)
@@ -306,7 +454,6 @@
                    fontSize:15
                  }
                },
                series: [{
                    name: '家庭号',
                    type: 'pie',