Browse Source

报表接口对接

zhangli 1 year ago
parent
commit
e3758a464f

+ 154 - 0
src/api/knowledge/statistics.js

@@ -0,0 +1,154 @@
+import rxAjax from '@/assets/js/ajax.js';
+// 栏目定义 api接口
+export const returnData = {};
+
+returnData.baseUrl= '/api-knowledge/analysis';
+// 组织访问量
+returnData.organizationVisits = returnData.baseUrl + '/organizationVisits'
+// 组织创建知识数量
+returnData.organizationKnowledges = returnData.baseUrl + '/organizationKnowledges'
+//组织创建和访问专辑数量
+returnData.organizationAlbums = returnData.baseUrl + '/organizationAlbums'
+//组织创建和访问地图数量
+returnData.organizationMaps = returnData.baseUrl + '/organizationMaps'
+//组织访问量
+returnData.organizationSearchs = returnData.baseUrl + '/organizationSearchs'
+// 用户访问总量
+returnData.totalUserVisits=function (parameter) {
+  var url= returnData.baseUrl + '/totalUserVisits'
+  return rxAjax.get(url,parameter).then (res => {
+    return res
+  })
+}
+
+// 各板块访问量分布
+returnData.moduleUserVisits=function (parameter) {
+  var url= returnData.baseUrl + '/moduleUserVisits'
+  return rxAjax.get(url,parameter).then (res => {
+    return res
+  })
+}
+
+// 各板块访问量分布(UV)
+returnData.moduleUserUniqueVisits=function (parameter) {
+  var url= returnData.baseUrl + '/moduleUserUniqueVisits'
+  return rxAjax.get(url,parameter).then (res => {
+    return res
+  })
+}
+// 各板块访问量分布(UV)
+returnData.moduleUserUniqueVisits=function (parameter) {
+  var url= returnData.baseUrl + '/moduleUserUniqueVisits'
+  return rxAjax.get(url,parameter).then (res => {
+    return res
+  })
+}
+//知识仓库统计
+//知识类型访问量分布
+returnData.knowledgeTypeVisitProportion=function (parameter) {
+  var url= returnData.baseUrl + '/knowledgeTypeVisitProportion'
+  return rxAjax.get(url,parameter).then (res => {
+    return res
+  })
+}
+//各一级分类知识创建数量
+returnData.level1KnowledgeHistogram=function (parameter) {
+  var url= returnData.baseUrl + '/level1KnowledgeHistogram'
+  return rxAjax.get(url,parameter).then (res => {
+    return res
+  })
+}
+//专辑统计
+//专辑创建总量
+returnData.albumAmount=function (parameter) {
+  var url= returnData.baseUrl + '/albumAmount'
+  return rxAjax.get(url,parameter).then (res => {
+    return res
+  })
+}
+//专辑页面访问量
+returnData.albumDetailVisits=function (parameter) {
+  var url= returnData.baseUrl + '/albumDetailVisits'
+  return rxAjax.get(url,parameter).then (res => {
+    return res
+  })
+}
+//各一级分类专辑创建数量
+returnData.level1AlbumHistogram=function (parameter) {
+  var url= returnData.baseUrl + '/level1AlbumHistogram'
+  return rxAjax.get(url,parameter).then (res => {
+    return res
+  })
+}
+//地图统计
+//地图创建总量
+returnData.mapAmount=function (parameter) {
+  var url= returnData.baseUrl + '/mapAmount'
+  return rxAjax.get(url,parameter).then (res => {
+    return res
+  })
+}
+//各类型地图创建数量
+returnData.typeMapPie=function (parameter) {
+  var url= returnData.baseUrl + '/typeMapPie'
+  return rxAjax.get(url,parameter).then (res => {
+    return res
+  })
+}
+//地图页面访问量
+returnData.mapPageHistogram=function (parameter) {
+  var url= returnData.baseUrl + '/mapPageHistogram'
+  return rxAjax.get(url,parameter).then (res => {
+    return res
+  })
+}
+//搜索统计
+//各业务系统分布
+returnData.searchSystemDetailVisits=function (parameter) {
+  var url= returnData.baseUrl + '/searchSystemDetailVisits'
+  return rxAjax.get(url,parameter).then (res => {
+    return res
+  })
+}
+//组织访问量
+returnData.organizationSearchsColumns=function (parameter) {
+  var url= returnData.baseUrl + '/organizationSearchs'
+  return rxAjax.postJson(url,parameter).then (res => {
+    return res
+  })
+}
+
+//获取当前时间
+returnData.getNowDate=function(){
+  const nowDate = new Date();
+  const date = {
+    year: nowDate.getFullYear(),
+    month: nowDate.getMonth() + 1,
+    date: nowDate.getDate(),
+    hours: nowDate.getHours(),
+    minutes: nowDate.getMinutes(),
+    seconds: nowDate.getSeconds(),
+  };
+
+  const newmonth = date.month > 10 ? date.month : "0" + date.month;
+  const newday = date.date > 10 ? date.date : "0" + date.date;
+  const newminutes = date.minutes > 10 ? date.minutes : "0" + date.minutes;
+  const newseconds = date.seconds > 10 ? date.seconds : "0" + date.seconds;
+  //   const newminutes = date.minutes < 10 ? "0" + date.minutes : date.minutes;
+  //   const newseconds = date.seconds < 10 ? "0" + date.seconds : date.seconds;
+
+  let dateTime =
+    date.year +
+    "-" +
+    newmonth +
+    "-" +
+    newday +
+    " " +
+    date.hours +
+    ":" +
+    newminutes +
+    ":" +
+    newseconds;
+    return dateTime;
+}
+export default returnData

+ 129 - 23
src/views/modules/knowledge/statistics/album.vue

@@ -3,41 +3,45 @@
     <div slot="center" style>
       <rx-fit>   
         <div slot="toolheader" border="false" foldbtn="false">
-          <top-nav title="知识专辑统计" time="2021-10-15 10:00:01"></top-nav>
+          <top-nav @callBack="freshData" title="知识专辑统计" :time="timeData"></top-nav>
         </div>    
         <div class="echart-style">
           <div style="width:58%;">
             <div class="line-style">
-              <div :style="{'border-bottom' : tabStatus ? '2px solid #1890ff' : 'none'}" @click="handleTabsChange">
-                用户访问总量-10000(uv)
+              <div :style="{'border-bottom' : tabStatus ? '2px solid #1890ff' : 'none'}" @click="handleTabsChange(true)">
+                用户访问总量-{{barDataNum}}(uv)
               </div>
-              <div :style="{'border-bottom' : !tabStatus ? '2px solid #1890ff' : 'none'}" @click="handleTabsChange">
-                专辑创建总量-20000
+              <div :style="{'border-bottom' : !tabStatus ? '2px solid #1890ff' : 'none'}" @click="handleTabsChange(false)">
+                专辑创建总量-{{barDataNumCreat}}
               </div>
             </div>
-            <line-echart :barData="barData"></line-echart>
+            <line-echart @setbarDataNumCreat="setbarDataNumCreat" @setbarDataNum="setbarDataNum" ref="lineEchart"></line-echart>
           </div>
           <div style="width:40%;">
-            <div class="album-style">
+            <div class="album-style" style="width:90%;z-index: 10;">
               专辑页面访问量TOP10
               <span>(pv)</span>
+              <pieChange ref="pieChange" @typeChange="typeChange"></pieChange>
             </div>
-            <pie-echart></pie-echart>
+            <rose-echart v-if="peitype==1" :roseData="pieData"></rose-echart>
+            <pie-echart v-else :pieData="pieData" :pieDataTitleLeft="pieDataTitleLeft" :pieDataTitleRight="pieDataTitleRight"></pie-echart>
+            
           </div>
         </div>
         <div class="bar-style">
           <div>各分类专辑及收录知识分布
           </div>
-          <bar-echart></bar-echart>
+          <bar-echart @legendselectchanged="legendselectchanged" :barTitle="barTitle" :barXData="barXData" :barData="barData"></bar-echart>
         </div>
         <div class="table-style">
           <div>
              组织创建和访问专辑数量TOP10
           </div>
           <rx-grid
+            ref="table"
             style="background: #fff;min-height: 400px;"
             :columns="columns"
-            :url="api.findAllKnowledge"
+            :url="statistics.organizationAlbums"
             :queryParam="queryParam"
             data-field="result.data"
             :heightAuto="true"
@@ -53,52 +57,154 @@
 
 <script>
 import topNav from './components/topNav'
+import pieChange from './components/pieChange'
+import roseEchart from './components/RoseEchart';
 import lineEchart from './components/LineEchart';
 import pieEchart from './components/PieEchart';
 import barEchart from './components/BarEchart';
-import api from '@/api/knowledge/manage';
+import statistics from '@/api/knowledge/statistics'
 export default {
   name: 'synthesize',
   components: {
     topNav,
     lineEchart,
     pieEchart,
-    barEchart
+    barEchart,
+    pieChange,
+    roseEchart
   },
   data() {
     return {
-      api,
+      peitype:0,
+      barDataNum:0,
+      barDataNumCreat:0,
+      pieData:[],
+      pieDataTitleLeft:[],
+      pieDataTitleRight:[],
+      timeData:'',
+      sort:'knowledgeDesc',
+      type:'month',
+      statistics,
       tabStatus: true,
-      barData: [0, 200, 901, 300, 1290, 133,1, 200, 901, 300, 1290, 0],
-      queryParam: {},
+      barTitle:['专辑数量','知识收录数量'],
+      barXData:[],
+      barData:{
+        dataBas0:[],
+        dataBas1:[]
+      },
+      queryParam: {
+        type:'month'
+      },
       columns:  [
         {
           title: '公司名称',
-          dataIndex: 'author',
+          dataIndex: 'company',
           align: 'center',
         },
         {
           title: '专辑创建总量',
-          dataIndex: 'author',
+          dataIndex: 'album',
           align: 'center',
           sorter: true,
-          sortField: 'author'
+          sortField: 'album'
         },
         {
           title: '专辑访问量pv',
-          dataIndex: 'author',
+          dataIndex: 'pv',
           align: 'center',
           sorter: true,
-          sortField: 'author'
+          sortField: 'pv'
         }
       ]
     }
   },
-  created() {
+  mounted() {
+    this.gettotalUserVisits()
+    this.getalbumDetailVisits();
+    this.getlevel1AlbumHistogram();
+    this.timeData = statistics.getNowDate()
   },
   methods: {
-    handleTabsChange() {
-      this.tabStatus = !this.tabStatus
+    typeChange(data){
+      this.peitype=data
+    },
+    //柱状图切换
+    legendselectchanged(data){
+      console.log(data)
+      if(data['知识收录数量']&&this.sort=='albumDesc'){
+        this.sort='knowledgeDesc'
+        this.getlevel1AlbumHistogram()
+      }
+      if(data['知识收录数量']==false&&data['专辑数量']==true&&this.sort=='knowledgeDesc'){
+        this.sort='albumDesc'
+        this.getlevel1AlbumHistogram()
+      }
+    },
+    freshData(data){
+      this.type = data
+      this.gettotalUserVisits()
+      this.getalbumDetailVisits();
+      this.getlevel1AlbumHistogram();
+      this.queryParam.type=data
+      this.$refs.table.loadData();
+      this.timeData = statistics.getNowDate()
+    },
+    //用户访问总量
+    gettotalUserVisits(){
+      this.$nextTick(()=>{
+        this.$refs.lineEchart.gettotalUserVisits({module: 'album',type:this.type,tabStatus:this.tabStatus})
+      })
+    },
+    setbarDataNum(data){
+      this.barDataNum=data
+    },
+    setbarDataNumCreat(data){
+      this.barDataNumCreat=data
+    },
+    //各一级分类知识创建数量
+    getalbumDetailVisits(){
+      this.$refs.pieChange.changeType(0)
+      this.peitype=0
+      statistics.albumDetailVisits({type:this.type}).then(res => {
+        let pieData=[];
+        let pieDataTitleLeft=[];
+        let pieDataTitleRight=[];
+        res.data.forEach((element,index) => {
+          let tempData={ value: element.value, name: element.name }
+          pieData.push(tempData)
+          if(index<5){
+            pieDataTitleLeft.push(element.name)
+          }else{
+            pieDataTitleRight.push(element.name)
+          }
+        })
+        this.pieData = pieData
+        this.pieDataTitleLeft = pieDataTitleLeft
+        this.pieDataTitleRight = pieDataTitleRight
+      })
+    },
+    //各一级分类知识创建数量
+    getlevel1AlbumHistogram(){
+      statistics.level1AlbumHistogram({type:this.type,sort:this.sort}).then(res => {
+        let barXData=[]
+        let barData={
+          dataBas0:[],
+          dataBas1:[]
+        }
+        res.data.forEach(element => {
+          barXData.push(element.label)
+          barData.dataBas0.push(element.album)
+          barData.dataBas1.push(element.knowledge)
+        })
+        this.barXData=barXData,
+        this.barData=barData
+      })
+    },
+    handleTabsChange(flag) {
+      if(this.tabStatus!=flag){
+        this.tabStatus = flag
+        this.gettotalUserVisits()
+      }
     }
   }
 }

+ 50 - 26
src/views/modules/knowledge/statistics/components/BarEchart.vue

@@ -1,5 +1,5 @@
 <template>
-  <common-echart :option="option" height="380px"></common-echart>
+  <common-echart @legendselectchanged="legendselectchanged" :option="option" height="380px"></common-echart>
 </template>
 
 <script>
@@ -17,11 +17,26 @@ export default {
     barData: {
       type: Array,
       default: () => []
+    },
+    barTitle: {
+      type: Array,
+      default: () => []
     }
   },
   computed: {
     option() {
+      let showNum=Math.floor(window.innerWidth*0.8276/(65*this.barData.dataBas0.length)*100)
       return {
+        toolbox: {//图形转换
+          feature: {
+              magicType: {
+                  show: true,
+                  type: ['line', 'bar']
+              }
+          },
+          right:'4%'
+        },
+        name:'barOption',
         xAxis: {
           type: "category",
           offset: 10,
@@ -41,15 +56,13 @@ export default {
               return value;
             }
           },
-          data: ['一级分类A123', '一级分类B', '一级分类C', '一级分类D', '一级分类E', '一级分类F', '一级分类G',
-          '一级分类A', '一级分类B', '一级分类C', '一级分类D', '一级分类E', '一级分类F', '一级分类G',
-          '一级分类A', '一级分类B', '一级分类C', '一级分类D', '一级分类E', '一级分类F', '一级分类G',
-          '一级分类A', '一级分类B', '一级分类C', '一级分类D', '一级分类E', '一级分类F', '一级分类G',]
+          data: this.barXData
         },
         yAxis: {
           type: "value",
            offset: 15,
         },
+        
         tooltip: {
           show: true,
           trigger: 'axis',
@@ -74,45 +87,39 @@ export default {
           }
         },
         grid: {
-          left: '6.8%',
-          right: '3%'
+          left: '3.3%',
+          right: '3%',
+          containLabel: true
         },
         legend: {
           icon: 'roundRect',
           top: '2.5%',
           data: [
             {
-              name: '文档知识',
+              name: this.barTitle[0],
               itemStyle: {
                 color: '#1890ff'
               }
             },
             {
-              name: '维基知识',
+              name: this.barTitle[1],
               itemStyle: {
                 color: '#ffc20d'
               }
             }
           ],
         },
-        dataZoom: [ {
-          type: 'inside',// 内置于坐标系中
-          start: 0,
-          end: 80,
-          xAxisIndex: [0],
-          zoomLock: true,
-        }],
-        toolbox: {
-          feature: {
-            dataZoom: {
-              show: false
-            }
+        dataZoom: [
+          {
+            show: true,
+            start: 0,
+            end: showNum
           }
-        },
+        ],
         series: [
           {
-            name: '文档知识',
-            data: [120, 200, 150, 80, 70, 110, 130, 120, 200, 150, 80, 70, 110, 130,120, 200, 150, 80, 70, 110, 130,120, 200, 150, 80, 70, 110, 130],
+            name: this.barTitle[0],
+            data: this.barData.dataBas0,
             type: "bar",
             barGap: 0, 
             showBackground: false,
@@ -136,8 +143,8 @@ export default {
             },
           },
           {
-            name: '维基知识',
-            data: [250, 200, 150, 80, 70, 110, 130,120, 200, 150, 80, 70, 110, 130,120, 200, 150, 80, 70, 110, 130,120, 200, 150, 80, 70, 110, 130],
+            name: this.barTitle[1],
+            data: this.barData.dataBas1,
             type: "bar",
             showBackground: false,
             barWidth: '10px',
@@ -162,6 +169,23 @@ export default {
         ]
       };
     }
+  },
+  data() {
+    return {
+      flag: false
+    }
+  },
+  methods: {
+    legendselectchanged(data) {
+      let that=this
+      if(this.flag==false){
+        this.flag=true
+        this.$emit('legendselectchanged',data)
+      }
+      setTimeout(function(){
+        that.flag=false
+      },200)
+    }
   }
 };
 </script>

+ 21 - 21
src/views/modules/knowledge/statistics/components/BarEchartOne.vue

@@ -21,7 +21,17 @@ export default {
   },
   computed: {
     option() {
+      let showNum=Math.floor(window.innerWidth*0.8276/(50*this.barData.length)*100)
       return {
+        toolbox: {//图形转换
+          feature: {
+              magicType: {
+                  show: true,
+                  type: ['line', 'bar']
+              }
+          },
+          right:'4%'
+        },
         xAxis: {
           type: "category",
           offset: 10,
@@ -41,10 +51,7 @@ export default {
               return value;
             }
           },
-          data: ['一级分类A123', '一级分类B', '一级分类C', '一级分类D', '一级分类E', '一级分类F', '一级分类G',
-          '一级分类A', '一级分类B', '一级分类C', '一级分类D', '一级分类E', '一级分类F', '一级分类G',
-          '一级分类A', '一级分类B', '一级分类C', '一级分类D', '一级分类E', '一级分类F', '一级分类G',
-          '一级分类A', '一级分类B', '一级分类C', '一级分类D', '一级分类E', '一级分类F', '一级分类G',]
+          data: this.barXData
         },
         yAxis: {
           type: "value",
@@ -63,27 +70,20 @@ export default {
           },
         },
         grid: {
-          left: '6.8%',
-          right: '3%'
+          left: '3.3%',
+          right: '3%',
+          containLabel: true
         },
-        dataZoom: [ {
-          type: 'inside',// 内置于坐标系中
-          start: 0,
-          end: 80,
-          xAxisIndex: [0],
-          zoomLock: true,
-        }],
-        toolbox: {
-          feature: {
-            dataZoom: {
-              show: false
-            }
+        dataZoom: [
+          {
+            show: true,
+            start: 0,
+            end: showNum
           }
-        },
+        ],
         series: [
           {
-            name: '文档知识',
-            data: [120, 200, 150, 80, 70, 110, 130, 120, 200, 150, 80, 70, 110, 130,120, 200, 150, 80, 70, 110, 130,120, 200, 150, 80, 70, 110, 130],
+            data: this.barData,
             type: "bar",
             barGap: 0, 
             showBackground: false,

+ 80 - 11
src/views/modules/knowledge/statistics/components/LineEchart.vue

@@ -5,26 +5,87 @@
 <script>
 /* 组件 */
 import commonEchart from "./commonEchart";
+import statistics from '@/api/knowledge/statistics'
 export default {
   components: {
     commonEchart
   },
   props: {
-    barXData: {
-      type: Array,
-      default: () => []
-    },
-    barData: {
-      type: Array,
-      default: () => []
-    }
+    
   },
   data() {   
-    return {}
+    return {
+      barDataX:[],
+      barDataPv:[],
+      barDataUv:[],
+      dataBas:null
+    }
+  },
+  methods: {
+    gettotalUserVisits(data){
+      this.dataBas=data
+      let barDataUv=[];
+      let barDataPv=[];
+      let barDataX=[];
+      statistics.totalUserVisits(data).then(res => {
+        this.$emit('setbarDataNum',res.data.total)
+        if(!((data.module=='album'||data.module=='map')&&data.tabStatus==false)){
+          res.data.lables.forEach(element => {
+            barDataUv.push(element.uv)
+            barDataPv.push(element.pv)
+            barDataX.push(element.name)
+          })
+          this.barDataUv=barDataUv
+          this.barDataPv=barDataPv
+          this.barDataX=barDataX
+        }
+      });
+      if(data.module=='album'){
+        let dataGet={
+          type:data.type
+        }
+        statistics.albumAmount(dataGet).then(res => {
+          if(data.tabStatus==false){
+            res.data.lables.forEach(element => {
+              barDataUv.push(element.value)
+              barDataX.push(element.name)
+            })
+            this.barDataUv=barDataUv
+            this.barDataX=barDataX
+          }
+          this.$emit('setbarDataNumCreat',res.data.total)
+        })
+      }
+      if(data.module=='map'){
+        let dataGet={
+          type:data.type
+        }
+        statistics.mapAmount(dataGet).then(res => {
+          if(data.tabStatus==false){
+            res.data.lables.forEach(element => {
+              barDataUv.push(element.value)
+              barDataX.push(element.name)
+            })
+            this.barDataUv=barDataUv
+            this.barDataX=barDataX
+          }
+          this.$emit('setbarDataNumCreat',res.data.total)
+        })
+      }
+    }
   },
   computed: {
     option() {
       return {
+        toolbox: {//图形转换
+          feature: {
+              magicType: {
+                  show: true,
+                  type: ['line', 'bar']
+              }
+          },
+          right:'4%'
+        },
         // title: {
         //   text: '用户总访问量-10000',
         //   top: 20,
@@ -40,7 +101,7 @@ export default {
           axisTick: {
             show: false
           },
-          data: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月']
+          data: this.barDataX
         },
         yAxis: {
           type: 'value',
@@ -60,13 +121,21 @@ export default {
           axisPointer: {
             type: 'none',
           },
+          formatter: params => {
+            let dataIndex=params[0].dataIndex
+            if(this.dataBas.tabStatus==false){
+              return `创建数量:${this.barDataUv[dataIndex]}`
+            }else{
+              return `pv数量:${this.barDataPv[dataIndex]}</br>uv数量:${this.barDataUv[dataIndex]}`
+            }
+          }
         },
         grid: {
           left: '12%'
         },
         series: [
           {
-            data: this.barData,
+            data: this.barDataUv,
             type: 'line',
             smooth: true,
             symbolSize: 1,

+ 18 - 18
src/views/modules/knowledge/statistics/components/PieEchart.vue

@@ -13,6 +13,14 @@ export default {
     pieData: {
       type: Array,
       default: () => []
+    },
+    pieDataTitleLeft: {
+      type: Array,
+      default: () => []
+    },
+    pieDataTitleRight: {
+      type: Array,
+      default: () => []
     }
   },
   computed: {
@@ -22,29 +30,32 @@ export default {
           show: true,
           trigger: 'item',
           triggerOn: 'mousemove',
-          formatter: '{c}'
+          //formatter: '{c}'
+          formatter: params => {
+            return params.data.name+`:${params.data.value}`
+          }
         },
         legend: [
           {
             orient: 'vertical',
-            data: ['测试专辑编辑编辑专辑', 'B', 'C', 'D', 'E'],
+            data: this.pieDataTitleLeft,
             itemWidth: 15,
-            right: '20%',
+            right: '30%',
             top: 'middle',
             formatter: function (name) {
               if(name.length < 6) return name
-              return name.slice(0, 6) + '\n' + name.slice(6);
+              return name.slice(0, 6) +'...';
             }
           },
           {
             orient: 'vertical',
-            data: ['F', 'G', 'H', 'I', 'J'],
+            data: this.pieDataTitleRight,
             itemWidth: 15,
             right: '10%',
             top: 'middle',
             formatter: function (name) {
               if(name.length < 6) return name
-              return name.slice(0, 6) + '\n' + name.slice(6);
+              return name.slice(0, 6) +'...';
             }
           }
         ],
@@ -74,18 +85,7 @@ export default {
             labelLine: {
               show: false
             },
-            data: [
-              { value: 1048, name: '测试专辑编辑编辑专辑' },
-              { value: 735, name: 'B' },
-              { value: 580, name: 'C' },
-              { value: 484, name: 'D' },
-              { value: 300, name: 'E' },
-              { value: 300, name: 'F' },
-              { value: 300, name: 'G' },
-              { value: 300, name: 'H' },
-              { value: 300, name: 'I' },
-              { value: 300, name: 'J' },
-            ]
+            data: this.pieData
           }
         ]
       };

+ 3 - 1
src/views/modules/knowledge/statistics/components/RoseEchart.vue

@@ -22,7 +22,9 @@ export default {
           show: true,
           trigger: 'item',
           triggerOn: 'mousemove',
-          formatter: '{c}'
+          formatter: params => {
+            return `${params.data.name.substr(params.data.name.indexOf('%')+2)}:${params.data.value}`
+          }
         },
         color: ["rgba(24,144,255,0.2)","rgba(24,144,255,1)","rgba(24,144,255,0.5)","rgba(24,144,255,0.8)"],
         series: [

+ 6 - 0
src/views/modules/knowledge/statistics/components/commonEchart.vue

@@ -54,8 +54,14 @@ export default {
   },
   methods: {
      _initEchart() {
+      let that=this
       const echartInstance = echarts.init(this.$refs.baseEchartRef);
       echartInstance.setOption(this.option);
+      echartInstance.on('legendselectchanged', function (params) {
+        if(that.option.name=='barOption'){
+          that.$emit('legendselectchanged',params.selected)
+        }
+      });
       // 监听window尺寸的变化
       // echartInstance.resize();
       // window.addEventListener("resize", () => {

+ 62 - 0
src/views/modules/knowledge/statistics/components/pieChange.vue

@@ -0,0 +1,62 @@
+<template>
+  <div class="pieTypeBox">
+    <a-tooltip placement="bottom" overlayClassName="tooltipBoxpieChange">
+      <template slot="title">
+        <span style="color:#3e98c5">切换为饼状图</span>
+      </template>
+      <a-icon @click="changePeitype(1)" type="pie-chart" :style="{marginRight:'0.5vw',color:peitype==1?'#3e98c5':'#6d6d6d','borderBottom': peitype==1?'1px solid #3e98c5':'1px solid #6d6d6d'}"/>
+    </a-tooltip>
+    <a-tooltip placement="bottom" overlayClassName="tooltipBoxpieChange">
+      <template slot="title">
+        <span style="color:#3e98c5">切换为环状图</span>
+      </template>
+      <a-icon @click="changePeitype(2)" type="chrome" :style="{color:peitype==2?'#3e98c5':'#6d6d6d','borderBottom': peitype==2?'1px solid #3e98c5':'1px solid #6d6d6d'}"/>    </a-tooltip>
+  </div>
+</template>
+
+<script>
+export default {
+  name: 'pieChange',
+  data() {
+    return {
+      peitype: 0
+    }
+  },
+  methods: {
+    changePeitype(type){
+      this.peitype=type
+      this.$emit('typeChange',type)
+    },
+    changeType(type){
+      this.peitype=type
+    }
+  }
+}
+</script>
+
+<style lang="less" scoped>
+.pieTypeBox{
+  float:right;
+  font-size: 0.8vw;
+  cursor: pointer;
+}
+.pieTypeBox i{
+  padding-bottom: 3px;
+}
+</style>
+<style lang="less">
+.tooltipBoxpieChange{
+  background: none;
+  padding-top: 0px;
+  .ant-tooltip-arrow{
+    display:none
+  }
+  .ant-tooltip-inner{
+    padding-top: 0px;
+    font-size: 12px;
+    background: none;
+    box-shadow: none;
+  }
+}
+
+</style>

+ 4 - 1
src/views/modules/knowledge/statistics/components/topNav.vue

@@ -33,12 +33,15 @@ export default {
   data() {
     return {
       lookIndex: 0,
-      lookData: ['按月查看','按年查看','查看全部']
+      lookData: ['按月查看','按年查看','查看全部'],
+      dataNameArr:['month','year','total']
     }
   },
   methods: {
     handleSearchClick(index) {
       this.lookIndex = index
+      console.log(this.dataNameArr[index])
+      this.$emit('callBack',this.dataNameArr[index])
     }
   }
 }

+ 111 - 30
src/views/modules/knowledge/statistics/map.vue

@@ -3,25 +3,27 @@
     <div slot="center" style>
       <rx-fit>   
         <div slot="toolheader" border="false" foldbtn="false">
-          <top-nav title="知识地图统计" time="2021-10-15 10:00:01"></top-nav>
+          <top-nav @callBack="freshData" title="知识地图统计" :time="timeData"></top-nav>
         </div>    
         <div class="echart-style">
           <div style="width:58%;">
             <div class="line-style">
-              <div :style="{'border-bottom' : tabStatus ? '2px solid #1890ff' : 'none'}" @click="handleTabsChange">
-                用户访问总量-10000(uv)
+              <div :style="{'border-bottom' : tabStatus ? '2px solid #1890ff' : 'none'}" @click="handleTabsChange(true)">
+                用户访问总量-{{barDataNum}}(uv)
               </div>
-              <div :style="{'border-bottom' : !tabStatus ? '2px solid #1890ff' : 'none'}" @click="handleTabsChange">
-                地图创建总量-20000
+              <div :style="{'border-bottom' : !tabStatus ? '2px solid #1890ff' : 'none'}" @click="handleTabsChange(false)">
+                地图创建总量-{{barDataNumCreat}}
               </div>
             </div>
-            <line-echart :barData="barData"></line-echart>
+            <line-echart @setbarDataNumCreat="setbarDataNumCreat" @setbarDataNum="setbarDataNum" ref="lineEchart"></line-echart>
           </div>
           <div style="width:40%;">
-            <div class="album-style">
+            <div class="album-style" style="width:90%;z-index: 10;">
              各类型地图创建量分布
+             <pieChange ref="pieChange" @typeChange="typeChange"></pieChange>
             </div>
-            <rose-echart :roseData="roseData"></rose-echart>
+            <rose-echart v-if="peitype!=2" :roseData="roseData"></rose-echart>
+            <pie-echart v-else :pieData="pieData" :pieDataTitleLeft="pieDataTitleLeft" :pieDataTitleRight="pieDataTitleRight"></pie-echart>
           </div>
         </div>
         <div class="bar-style">
@@ -29,16 +31,17 @@
             地图页面访问量分布
               <span>(pv)</span>
           </div>
-          <bar-echart-one></bar-echart-one>
+          <bar-echart-one :barXData="barXData" :barData="barDataNew"></bar-echart-one>
         </div>
         <div class="table-style">
           <div>
             组织创建和访问地图数量TOP10
           </div>
           <rx-grid
+            ref="table"
             style="background: #fff;min-height: 400px;"
             :columns="columns"
-            :url="api.findAllKnowledge"
+            :url="statistics.organizationMaps"
             :queryParam="queryParam"
             data-field="result.data"
             :heightAuto="true"
@@ -56,60 +59,138 @@
 import topNav from './components/topNav'
 import lineEchart from './components/LineEchart';
 import roseEchart from './components/RoseEchart';
+import pieChange from './components/pieChange'
+import pieEchart from './components/PieEchart';
 import barEchartOne from './components/BarEchartOne';
-import api from '@/api/knowledge/manage';
+import statistics from '@/api/knowledge/statistics'
 export default {
   name: 'synthesize',
   components: {
     topNav,
     lineEchart,
     roseEchart,
-    barEchartOne
+    barEchartOne,
+    pieChange,
+    pieEchart
   },
   data() {
     return {
-      api,
+      peitype:0,
+      barDataNum:0,
+      barDataNumCreat:0,
+      barDataNew:[],
+      barXData:[],
+      type:'month',
+      timeData:'',
+      statistics,
       tabStatus: true,
-      barData: [0, 200, 901, 300, 1290, 133,1, 200, 901, 300, 1290, 0],
       roseData: [
-        { value: 19, name: '19% 新人地图' },
-        { value: 40, name: '40% 岗位地图' },
-        { value: 20, name: '20% 制度地图' },
-        { value: 21, name: '21% 方案地图' }
       ],
+      pieData:[],
+      pieDataTitleLeft:[],
+      pieDataTitleRight:[],
       queryParam: {},
       columns:  [
         {
           title: '公司名称',
-          dataIndex: 'author',
+          dataIndex: 'company',
           align: 'center',
         },
         {
           title: '地图创建总量',
-          dataIndex: 'author',
+          dataIndex: 'map',
           align: 'center',
           sorter: true,
-          sortField: 'author'
+          sortField: 'map'
         },
         {
           title: '地图访问量pv',
-          dataIndex: 'author',
+          dataIndex: 'pv',
           align: 'center',
           sorter: true,
-          sortField: 'author'
+          sortField: 'pv'
         }
       ]
     }
   },
-  created() {
+  mounted() {
+    this.gettotalUserVisits()
+    this.gettypeMapPie();
+    this.getmapPageHistogram();
+    this.timeData = statistics.getNowDate()
   },
   methods: {
-    handleTabsChange() {
-      this.tabStatus = !this.tabStatus
-      if(this.tabStatus) {
-        this.barData = [20, 5000, 901, 3000, 1290, 1,4000, 200, 6000, 300, 2, 4000]
-      } else {
-        this.barData = [1000, 1, 6000, 300, 2000, 7000,1, 5000, 9101, 300, 2000, 5]
+    typeChange(data){
+      this.peitype=data
+    },
+    freshData(data){
+      this.type = data
+      this.gettotalUserVisits()
+      this.gettypeMapPie();
+      this.getmapPageHistogram();
+      this.queryParam.type=data
+      this.$refs.table.loadData();
+      this.timeData = statistics.getNowDate()
+    },
+    //用户访问总量
+    gettotalUserVisits(){
+      this.$nextTick(()=>{
+        this.$refs.lineEchart.gettotalUserVisits({module: 'map',type:this.type,tabStatus:this.tabStatus})
+      })
+    },
+    setbarDataNum(data){
+      this.barDataNum=data
+    },
+    setbarDataNumCreat(data){
+      this.barDataNumCreat=data
+    },
+    //各类型地图创建数量
+    gettypeMapPie(){
+      this.$refs.pieChange.changeType(0)
+      this.peitype=0
+      statistics.typeMapPie({type:this.type}).then(res => {
+        let roseData=[]
+        let pieData=[]
+        let pieDataTitleLeft=[]
+        let pieDataTitleRight=[]
+        res.data.forEach((element,index) => {
+          let tempData={
+            value: element.maps,
+            name: Math.floor(element.percentage*100)+'% '+element.type
+          }
+          roseData.push(tempData)
+          let tempData0={ value: element.maps, name: element.type }
+          pieData.push(tempData0)
+          if(index<5){
+            pieDataTitleLeft.push(element.type)
+          }else{
+            pieDataTitleRight.push(element.type)
+          }
+        })
+        this.roseData = roseData
+        this.pieData = pieData
+        this.pieDataTitleLeft = pieDataTitleLeft
+        this.pieDataTitleRight = pieDataTitleRight
+      })
+    },
+    //地图页面访问量
+    getmapPageHistogram(){
+      statistics.mapPageHistogram({type:this.type}).then(res => {
+        let barXData=[]
+        let barDataNew=[]
+        res.data.forEach(element => {
+          barXData.push(element.label)
+          barDataNew.push(element.pv)
+        })
+        console.log(barXData)
+        this.barXData=barXData
+        this.barDataNew=barDataNew
+      })
+    },
+    handleTabsChange(flag) {
+      if(this.tabStatus!=flag){
+        this.tabStatus = flag
+        this.gettotalUserVisits()
       }
     }
   }

+ 95 - 74
src/views/modules/knowledge/statistics/search.vue

@@ -3,21 +3,23 @@
     <div slot="center" style>
       <rx-fit>   
         <div slot="toolheader" border="false" foldbtn="false">
-          <top-nav title="搜索服务统计" time="2021-10-15 10:00:01"></top-nav>
+          <top-nav @callBack="freshData" title="搜索服务统计" :time="timeData"></top-nav>
         </div>    
         <div class="echart-style">
           <div style="width:58%;">
-            <div>用户访问总量-10000
+            <div>用户访问总量-{{barDataNum}}
               <span>(uv)</span>
             </div>
-            <line-echart :barData="barData"></line-echart>
+            <line-echart @setbarDataNum="setbarDataNum" ref="lineEchart"></line-echart>
           </div>
           <div style="width:40%;">
-            <div>
+            <div style="width:90%;z-index: 10;">
               各业务系统访问量分布
               <span>(pv)</span>
+              <pieChange ref="pieChange" @typeChange="typeChange"></pieChange>
             </div>
-            <rose-echart :roseData="roseData"></rose-echart>
+            <rose-echart v-if="peitype!=2" :roseData="roseData"></rose-echart>
+            <pie-echart v-else :pieData="pieData" :pieDataTitleLeft="pieDataTitleLeft" :pieDataTitleRight="pieDataTitleRight"></pie-echart>
           </div>
         </div>
         <div class="table-style">
@@ -26,9 +28,10 @@
              <span>(pv)</span>
           </div>
           <rx-grid
+            ref="table"
             style="background: #fff;min-height: 400px;"
             :columns="columns"
-            :url="api.findAllKnowledge"
+            :url="statistics.organizationSearchs"
             :queryParam="queryParam"
             data-field="result.data"
             :heightAuto="true"
@@ -44,89 +47,107 @@
 
 <script>
 import topNav from './components/topNav'
+import pieChange from './components/pieChange'
 import lineEchart from './components/LineEchart';
 import roseEchart from './components/RoseEchart';
-import api from '@/api/knowledge/manage'
+import pieEchart from './components/PieEchart';
+import statistics from '@/api/knowledge/statistics'
 export default {
   name: 'synthesize',
   components: {
     topNav,
     lineEchart,
-    roseEchart
+    roseEchart,
+    pieEchart,
+    pieChange
   },
   data() {
     return {
-      api,
+      peitype:0,
+      barDataNum:0,
+      type:'month',
+      timeData:'',
+      statistics,
       barData: [0, 200, 901, 300, 1290, 133,1, 200, 901, 300, 1290, 0],
-      roseData: [
-        { value: 19, name: '19% 平展系统' },
-        { value: 40, name: '40% 工作管理系统' },
-        { value: 20, name: '20% EIP系统' },
-        { value: 21, name: '21% 网盘系统' },
-        { value: 21, name: '21% 知识管理系统' }
-      ],
-      queryParam: {},
-      columns:  [
-        {
-          title: '公司名称',
-          dataIndex: 'author',
-          align: 'center',
-        },
-        {
-          title: '访问总量',
-          dataIndex: 'author',
-          align: 'center',
-          sorter: true,
-          sortField: 'author'
-        },
-        {
-          title: '知识管理系统',
-          dataIndex: 'author',
-          align: 'center',
-          sorter: true,
-          sortField: 'author'
-        },
-        {
-          title: 'EIP系统',
-          dataIndex: 'author',
-          align: 'center',
-          sorter: true,
-          sortField: 'author'
-        },
-        {
-          title: 'DCC系统',
-          dataIndex: 'author',
-          align: 'center',
-          sorter: true,
-          sortField: 'author'
-        },
-        {
-          title: '工作管理系统',
-          dataIndex: 'author',
-          align: 'center',
-          sorter: true,
-          sortField: 'author'
-        },
-         {
-          title: '平展系统',
-          dataIndex: 'author',
-          align: 'center',
-          sorter: true,
-          sortField: 'author'
-        },
-         {
-          title: '网盘系统',
-          dataIndex: 'author',
-          align: 'center',
-          sorter: true,
-          sortField: 'author'
-        }
-      ]
+      roseData: [],
+      pieData:[],
+      pieDataTitleLeft:[],
+      pieDataTitleRight:[],
+      queryParam: {
+        type:'month'
+      },
+      columns:  []
     }
   },
-  created() {
+  mounted() {
+    statistics.organizationSearchsColumns({params:{type: "month"}}).then(res => {
+      res.result.columns.forEach(element => {
+        let temp={}
+        temp.title = element.title
+        temp.dataIndex = element.dataIndex
+        temp.align = 'center'
+        if(element.sortFiled!=''){
+          temp.sorter = true
+          temp.sortField = element.sortFiled
+        }
+        this.columns.push(temp)
+      });
+      console.log(this.columns)
+      this.gettotalUserVisits()
+      this.getsearchSystemDetailVisits();
+      this.timeData = statistics.getNowDate()
+    })
   },
   methods: {
+    typeChange(data){
+      this.peitype=data
+    },
+    freshData(data){
+      this.type = data
+      this.gettotalUserVisits()
+      this.getsearchSystemDetailVisits();
+      this.queryParam.type=data
+      this.$refs.table.loadData();
+      this.timeData = statistics.getNowDate()
+    },
+    //用户访问总量
+    gettotalUserVisits(){
+      this.$nextTick(()=>{
+        this.$refs.lineEchart.gettotalUserVisits({module: 'search',type:this.type})
+      })
+    },
+    //各业务系统分布
+    getsearchSystemDetailVisits(){
+      this.$refs.pieChange.changeType(0)
+      this.peitype=0
+      statistics.searchSystemDetailVisits({type:this.type}).then(res => {
+        let roseData=[]
+        let pieData=[]
+        let pieDataTitleLeft=[];
+        let pieDataTitleRight=[];
+        res.data.forEach((element,index) => {
+          let tempData={
+            value: element.value,
+            name: Math.floor(element.percentage*100)+'% '+element.label
+          }
+          roseData.push(tempData)
+          let tempData0={ value: element.value, name: element.label }
+          pieData.push(tempData0)
+          if(index<5){
+            pieDataTitleLeft.push(element.label)
+          }else{
+            pieDataTitleRight.push(element.label)
+          }
+        })
+        this.pieData = pieData
+        this.roseData = roseData
+        this.pieDataTitleLeft = pieDataTitleLeft
+        this.pieDataTitleRight = pieDataTitleRight
+      })
+    },
+    setbarDataNum(data){
+      this.barDataNum=data
+    },
   }
 }
 </script>

+ 101 - 34
src/views/modules/knowledge/statistics/synthesize.vue

@@ -3,28 +3,30 @@
     <div slot="center" style>
       <rx-fit>   
         <div slot="toolheader" border="false" foldbtn="false">
-          <top-nav title="综合统计" time="2021-10-15 10:00:01"></top-nav>
-        </div>    
+          <top-nav @callBack="freshData" title="综合统计" :time="timeData"></top-nav>
+        </div>
         <div class="echart-style">
           <div style="width:58%;">
-            <div>用户访问总量-10000
+            <div>用户访问总量-{{barDataNum}}
               <span>(uv)</span>
             </div>
-            <line-echart :barData="barData"></line-echart>
+            <line-echart @setbarDataNum="setbarDataNum" ref="lineEchart"></line-echart>
           </div>
           <div style="width:40%;">
-            <div>
+            <div style="width:90%;z-index: 10;">
               各版块访问量分布
               <span>(pv)</span>
+              <pieChange ref="pieChange" @typeChange="typeChange"></pieChange>
             </div>
-            <rose-echart :roseData="roseData"></rose-echart>
+            <rose-echart v-if="peitype!=2" :roseData="roseData"></rose-echart>
+            <pie-echart v-else :pieData="pieData" :pieDataTitleLeft="pieDataTitleLeft" :pieDataTitleRight="pieDataTitleRight"></pie-echart>
           </div>
         </div>
         <div class="card-style">
-          <little-card title="知识地图访问量(uv)" num="2696" :picture="mapPicture"></little-card>
-          <little-card title="知识专辑访问量(uv)" num="2696" :picture="albumPicture"></little-card>
-          <little-card title="知识仓库访问量(uv)" num="2696" :picture="warehousePicture"></little-card>
-          <little-card title="搜索服务访问量(uv)" num="2696" :picture="searchPicture"></little-card>
+          <little-card title="知识地图访问量(uv)" :num="dataNum.map" :picture="mapPicture"></little-card>
+          <little-card title="知识专辑访问量(uv)" :num="dataNum.album" :picture="albumPicture"></little-card>
+          <little-card title="知识仓库访问量(uv)" :num="dataNum.knowledge" :picture="warehousePicture"></little-card>
+          <little-card title="搜索服务访问量(uv)" :num="dataNum.search" :picture="searchPicture"></little-card>
         </div>
         <div class="table-style">
           <div>
@@ -32,9 +34,10 @@
              <span>(pv)</span>
           </div>
           <rx-grid
+            ref="table"
             style="background: #fff;min-height: 400px;"
             :columns="columns"
-            :url="api.findAllKnowledge"
+            :url="statistics.organizationVisits"
             :queryParam="queryParam"
             data-field="result.data"
             :heightAuto="true"
@@ -50,6 +53,7 @@
 
 <script>
 import topNav from './components/topNav'
+import pieChange from './components/pieChange'
 import lineEchart from './components/LineEchart';
 import roseEchart from './components/RoseEchart';
 import littleCard from './components/card';
@@ -57,77 +61,140 @@ import mapPicture from '@/assets/img/map.png'
 import albumPicture from '@/assets/img/album.png'
 import warehousePicture from '@/assets/img/warehouse.png'
 import searchPicture from '@/assets/img/search.png'
-import api from '@/api/knowledge/manage'
+import statistics from '@/api/knowledge/statistics'
+import pieEchart from './components/PieEchart';
 export default {
   name: 'synthesize',
   components: {
     topNav,
     lineEchart,
     roseEchart,
-    littleCard
+    littleCard,
+    pieEchart,
+    pieChange
   },
   data() {
     return {
-      api,
+      peitype:0,
+      barDataNum:0,
+      dataNum:{
+        map:0,
+        album:0,
+        knowledge:0,
+        search:0
+      },
+      type:'month',
+      timeData:'',
+      statistics,
       mapPicture,
       albumPicture,
       warehousePicture,
       searchPicture,
-      barData: [0, 200, 901, 300, 1290, 133,1, 200, 901, 300, 1290, 0],
-      roseData: [
-        { value: 19, name: '19% 知识仓库' },
-        { value: 40, name: '40% 知识地图' },
-        { value: 20, name: '20% 知识专辑' },
-        { value: 21, name: '21% 搜索服务' }
-      ],
-      queryParam: {},
+      roseData: [],
+      queryParam: {
+        type:'month'
+      },
       columns:  [
         {
           title: '公司名称',
-          dataIndex: 'author',
+          dataIndex: 'company',
           align: 'center',
         },
         {
           title: '总访问量',
-          dataIndex: 'author',
+          dataIndex: 'total',
           align: 'center',
           sorter: true,
-          sortField: 'author'
+          sortField: 'total'
         },
         {
           title: '知识仓库访问量',
-          dataIndex: 'author',
+          dataIndex: 'knowledge',
           align: 'center',
           sorter: true,
-          sortField: 'author'
+          sortField: 'knowledge'
         },
         {
           title: '知识专辑访问量',
-          dataIndex: 'author',
+          dataIndex: 'album',
           align: 'center',
           sorter: true,
-          sortField: 'author'
+          sortField: 'album'
         },
         {
           title: '知识地图访问量',
-          dataIndex: 'author',
+          dataIndex: 'map',
           align: 'center',
           sorter: true,
-          sortField: 'author'
+          sortField: 'map'
         },
         {
           title: '搜索服务访问量',
-          dataIndex: 'author',
+          dataIndex: 'search',
           align: 'center',
           sorter: true,
-          sortField: 'author'
+          sortField: 'search'
         },
       ]
     }
   },
-  created() {
+  mounted() {
+    this.gettotalUserVisits()
+    this.getmoduleUserVisits();
+    this.getmoduleUserUniqueVisits();
+    this.timeData = statistics.getNowDate()
   },
   methods: {
+    typeChange(data){
+      this.peitype=data
+    },
+    //刷新数据
+    freshData(data){
+      this.type = data
+      this.gettotalUserVisits()
+      this.getmoduleUserVisits();
+      this.getmoduleUserUniqueVisits();
+      this.queryParam.type=data
+      this.$nextTick(()=>{
+        this.$refs.table.loadData();
+      })
+      this.timeData = statistics.getNowDate()
+    },
+    //用户访问总量
+    gettotalUserVisits(){
+      this.$nextTick(()=>{
+        this.$refs.lineEchart.gettotalUserVisits({module: 'total',type:this.type})
+      })
+    },
+    setbarDataNum(data){
+      this.barDataNum=data
+    },
+    //各板块访问量分布
+    getmoduleUserVisits(){
+      this.$refs.pieChange.changeType(0)
+      this.peitype=0
+      statistics.moduleUserVisits({type:this.type}).then(res => {
+        this.roseData = [
+          { value: res.data.knowledge, name: Math.floor(res.data.knowledgePercentage*100)+'% 知识仓库' },
+          { value: res.data.map, name: Math.floor(res.data.mapPercentage*100)+'% 知识地图' },
+          { value: res.data.album, name: Math.floor(res.data.albumPercentage*100)+'% 知识专辑' },
+          { value: res.data.search, name: Math.floor(res.data.searchPercentage*100)+'% 搜索服务' }
+        ]
+        this.pieData=[
+          { value: res.data.knowledge, name: '知识仓库' },
+          { value: res.data.map, name: '知识地图' },
+          { value: res.data.album, name: '知识专辑' },
+          { value: res.data.search, name: '搜索服务' }
+        ]
+        this.pieDataTitleLeft=['知识仓库','知识地图','知识专辑','搜索服务']
+      })
+    },
+    //各板块访问量分布(UV)
+    getmoduleUserUniqueVisits(){
+      statistics.moduleUserUniqueVisits({module: 'total',type:this.type}).then(res => {
+        this.dataNum = res.data
+      })
+    }
   }
 }
 </script>

+ 114 - 22
src/views/modules/knowledge/statistics/warehouse.vue

@@ -3,36 +3,39 @@
     <div slot="center" style>
       <rx-fit>   
         <div slot="toolheader" border="false" foldbtn="false">
-          <top-nav title="知识仓库统计" time="2021-10-15 10:00:01"></top-nav>
+          <top-nav @callBack="freshData" title="知识仓库统计" :time="timeData"></top-nav>
         </div>    
         <div class="echart-style">
           <div style="width:58%;">
-            <div>用户访问总量-10000
+            <div>用户访问总量-{{barDataNum}}
               <span>(uv)</span>
             </div>
-            <line-echart :barData="barData"></line-echart>
+            <line-echart @setbarDataNum="setbarDataNum" ref="lineEchart"></line-echart>
           </div>
           <div style="width:40%;">
-            <div>
+            <div style="width:90%;z-index: 10;">
               知识类型页面访问量分布
               <span>(pv)</span>
+              <pieChange ref="pieChange" @typeChange="typeChange"></pieChange>
             </div>
-            <rose-echart :roseData="roseData"></rose-echart>
+            <rose-echart v-if="peitype!=2" :roseData="roseData"></rose-echart>
+            <pie-echart v-else :pieData="pieData" :pieDataTitleLeft="pieDataTitleLeft" :pieDataTitleRight="pieDataTitleRight"></pie-echart>
           </div>
         </div>
         <div class="bar-style">
           <div>各一级分类知识创建数量
           </div>
-          <bar-echart></bar-echart>
+          <bar-echart @legendselectchanged="legendselectchanged" :barTitle="barTitle" :barXData="barXData" :barData="barData"></bar-echart>
         </div>
         <div class="table-style">
           <div>
              组织创建知识数量TOP10
           </div>
           <rx-grid
+            ref="table"
             style="background: #fff;min-height: 400px;"
             :columns="columns"
-            :url="api.findAllKnowledge"
+            :url="statistics.organizationKnowledges"
             :queryParam="queryParam"
             data-field="result.data"
             :heightAuto="true"
@@ -50,58 +53,147 @@
 import topNav from './components/topNav'
 import lineEchart from './components/LineEchart';
 import roseEchart from './components/RoseEchart';
+import pieChange from './components/pieChange'
+import pieEchart from './components/PieEchart';
 import barEchart from './components/BarEchart';
-import api from '@/api/knowledge/manage';
+import statistics from '@/api/knowledge/statistics'
 export default {
   name: 'synthesize',
   components: {
     topNav,
     lineEchart,
     roseEchart,
-    barEchart
+    barEchart,
+    pieChange,
+    pieEchart
   },
   data() {
     return {
-      api,
-      barData: [0, 200, 901, 300, 1290, 133,1, 200, 901, 300, 1290, 0],
+      peitype:0,
+      barTitle:['文档知识','维基知识'],
+      barXData:[],
+      barData:{
+        dataBas0:[],
+        dataBas1:[]
+      },
+      barDataNum:0,
+      statistics,
+      type:'month',
+      sort:'wikiDesc',
+      timeData:'',
       roseData: [ 
-        { value: 70, name: '70% 文档知识' },
-        { value: 30, name: '19% 维基知识' },
       ],
-      queryParam: {},
+      pieData:[],
+      pieDataTitleLeft:[],
+      pieDataTitleRight:[],
+      queryParam: {
+        type:'month'
+      },
       columns:  [
         {
           title: '公司名称',
-          dataIndex: 'author',
+          dataIndex: 'company',
           align: 'center',
         },
         {
           title: '知识总量',
-          dataIndex: 'author',
+          dataIndex: 'total',
           align: 'center',
           sorter: true,
-          sortField: 'author'
+          sortField: 'total'
         },
         {
           title: '文档知识数量',
-          dataIndex: 'author',
+          dataIndex: 'archive',
           align: 'center',
           sorter: true,
-          sortField: 'author'
+          sortField: 'archive'
         },
         {
           title: '维基知识数量',
-          dataIndex: 'author',
+          dataIndex: 'wiki',
           align: 'center',
           sorter: true,
-          sortField: 'author'
+          sortField: 'wiki'
         }
       ]
     }
   },
-  created() {
+  mounted() {
+    this.gettotalUserVisits()
+    this.getknowledgeTypeVisitProportion();
+    this.getlevel1KnowledgeHistogram();
+    this.timeData = statistics.getNowDate()
   },
   methods: {
+    typeChange(data){
+      this.peitype=data
+    },
+    //柱状图切换
+    legendselectchanged(data){
+      console.log(data)
+      if(data['维基知识']&&this.sort=='archiveDesc'){
+        this.sort='wikiDesc'
+        this.getlevel1KnowledgeHistogram()
+      }
+      if(data['维基知识']==false&&data['文档知识']==true&&this.sort=='wikiDesc'){
+        this.sort='archiveDesc'
+        this.getlevel1KnowledgeHistogram()
+      }
+    },
+    //刷新数据
+    freshData(data){
+      this.type = data
+      this.gettotalUserVisits()
+      this.getknowledgeTypeVisitProportion();
+      this.getlevel1KnowledgeHistogram();
+      this.queryParam.type=data
+      this.$refs.table.loadData();
+      this.timeData = statistics.getNowDate()
+    },
+    //用户访问总量
+    gettotalUserVisits(){
+      this.$nextTick(()=>{
+        this.$refs.lineEchart.gettotalUserVisits({module: 'knowledge',type:this.type})
+      })
+    },
+    setbarDataNum(data){
+      this.barDataNum=data
+    },
+    //知识类型访问量分布
+    getknowledgeTypeVisitProportion(){
+      this.$refs.pieChange.changeType(0)
+      this.peitype=0
+      statistics.knowledgeTypeVisitProportion({type:this.type}).then(res => {
+        this.roseData = [
+          { value: res.data.archive, name: Math.floor(res.data.archivePercentage*100)+'% 文档知识' },
+          { value: res.data.wiki, name: Math.floor(res.data.wikiPercentage*100)+'% 维基知识' },
+        ]
+        this.pieData=[
+          { value: res.data.archive, name: '文档知识' },
+          { value: res.data.wiki, name: '维基知识' }
+        ]
+        this.pieDataTitleLeft=['文档知识','维基知识']
+      })
+    },
+    //各一级分类知识创建数量
+    getlevel1KnowledgeHistogram(){
+      statistics.level1KnowledgeHistogram({type:this.type,sort:this.sort}).then(res => {
+        let barXData=[]
+        let barData={
+          dataBas0:[],
+          dataBas1:[]
+        }
+        res.data.forEach(element => {
+          barXData.push(element.label)
+          barData.dataBas0.push(element.archive)
+          barData.dataBas1.push(element.wiki)
+        })
+        console.log(barXData)
+        this.barXData=barXData,
+        this.barData=barData
+      })
+    }
   }
 }
 </script>