123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607 |
- <template>
- <div>
- <div :class="$style.statistics">
- <ul>
- <li>
- <img src="../images/statistics-zsk.png" alt="" />
- <div>
- <p :class="$style.all"
- >知识库<span> {{ sdGet('graphicalData.knowledage?.all') || 0 }}</span></p
- >
- <p :class="$style.new"
- >本月上新<span>{{ sdGet('graphicalData.knowledage?.thisMonth') || 0 }}</span></p
- >
- </div>
- </li>
- <li>
- <img src="../images/statistics-zsdt.png" alt="" />
- <div>
- <p :class="$style.all"
- >知识地图<span>{{ sdGet('graphicalData.kmap?.all') || 0 }}</span></p
- >
- <p :class="$style.new"
- >本月上新<span>{{ sdGet('graphicalData.kmap?.thisMonth') || 0 }}</span></p
- >
- </div>
- </li>
- <li
- ><img src="../images/statistics-yzzs.png" alt="" />
- <div>
- <p :class="$style.all"
- >原子知识<span>{{ sdGet('graphicalData.atom?.all') || 0 }}</span></p
- ><p :class="$style.new"
- >本月上新<span>{{ sdGet('graphicalData.atom?.thisMonth') || 0 }}</span></p
- >
- </div>
- </li>
- <li
- ><img src="../images/statistics-fwcs.png" alt="" />
- <div>
- <p :class="$style.all"
- >访问次数<span>{{ sdGet('graphicalData.visits?.all') || 0 }}</span></p
- >
- <p :class="$style.new"
- >本月访问<span>{{ sdGet('graphicalData.visits?.thisMonth') || 0 }}</span></p
- >
- </div>
- </li>
- <li
- ><img src="../images/statistics-zjhd.png" alt="" />
- <div>
- <p :class="$style.all"
- >专家问答<span>{{ sdGet('graphicalData.expert?.all') || 0 }}</span></p
- >
- <p :class="$style.new"
- >本月上新<span>{{ sdGet('graphicalData.expert?.thisMonth') || 0 }}</span></p
- >
- </div>
- </li>
- </ul>
- </div>
- <div :class="$style.graphical">
- <a-row>
- <a-col :span="12">
- <div :class="$style.box">
- <a-card :bordered="false" :class="$style.cardBody">
- <div slot="title" :class="$style.fontslot"><a-icon type="fund" />访问趋势分析</div>
- <div :class="$style.echartclass">
- <sd-echart ref="visitBar" :class="$style.bar" :options="visitBar" autoresize />
- </div>
- </a-card>
- </div>
- </a-col>
- <a-col :span="12">
- <a-card :bordered="false" :class="$style.cardBody">
- <div slot="title" :class="$style.fontslot"><a-icon type="fund" />各部门访问量分布</div>
- <div :class="$style.echartclass">
- <sd-echart
- ref="deptVisitPie"
- :class="$style.piecenter"
- :options="deptVisitPie"
- autoresize
- />
- </div>
- </a-card>
- </a-col>
- </a-row>
- <a-row :class="$style.marginwidth">
- <a-col :span="12">
- <div :class="$style.box">
- <a-card :bordered="false" :class="$style.cardBody">
- <div slot="title" :class="$style.fontslot"
- ><a-icon type="fund" />各分类访问量分布</div
- >
- <div :class="$style.echartclass">
- <sd-echart
- ref="classPie"
- :class="$style.piecenter"
- :options="classPie"
- autoresize
- />
- </div>
- </a-card>
- </div>
- </a-col>
- <a-col :span="12">
- <a-card :bordered="false" :class="$style.cardBody">
- <div slot="title" :class="$style.fontslot"><a-icon type="fund" />知识投稿趋势</div>
- <div :class="$style.echartclass">
- <sd-echart
- ref="knowledgeBar"
- :class="$style.bars"
- :options="knowledgeBar"
- autoresize
- />
- </div>
- </a-card>
- </a-col>
- </a-row>
- <a-row :class="$style.marginwidth">
- <a-col :span="12">
- <div :class="$style.box">
- <a-card :bordered="false" :class="$style.cardBody">
- <div slot="title" :class="$style.fontslot"
- ><a-icon type="fund" />知识投稿部门来源分布</div
- >
- <div :class="$style.echartclass">
- <sd-echart
- ref="knowledgeClassPie"
- :class="$style.piecenter"
- :options="knowledgeClassPie"
- autoresize
- />
- </div>
- </a-card>
- </div>
- </a-col>
- <a-col :span="12">
- <a-card :bordered="false" :class="$style.cardBody">
- <div slot="title" :class="$style.fontslot"
- ><a-icon type="fund" />知识投稿分类来源分布</div
- >
- <div :class="$style.echartclass">
- <sd-echart
- ref="knowledgeSourcePie"
- :class="$style.piecenter"
- :options="knowledgeSourcePie"
- autoresize
- />
- </div>
- </a-card>
- </a-col>
- </a-row>
- </div>
- </div>
- </template>
- <script>
- // 为了按需加载,下面的组件需要手工导入
- import 'echarts/lib/chart/pie'
- import 'echarts/lib/chart/pictorialBar'
- import 'echarts/lib/component/title'
- import 'echarts/lib/chart/bar'
- import 'echarts/lib/component/legend'
- import 'echarts/lib/component/legendScroll'
- import 'echarts/lib/component/tooltip'
- import KmKnowledageService from '../km-knowledage-service'
- import components from './_import-components/km-statistics-graphical-import'
- const echarts = require('echarts/lib/echarts')
- const visitBar = {
- tooltip: {
- trigger: 'axis',
- axisPointer: {
- // 坐标轴指示器,坐标轴触发有效
- type: 'shadow', // 默认为直线,可选为:'line' | 'shadow'
- },
- },
- xAxis: {
- type: 'category',
- axisTick: {
- alignWithLabel: true,
- },
- axisLabel: {
- rotate: 40,
- interval: 0,
- },
- },
- yAxis: {
- type: 'value',
- },
- series: [
- {
- name: '访问量',
- type: 'bar',
- barWidth: 8, // 固定柱子宽度
- },
- ],
- }
- const deptVisitPie = {
- tooltip: {
- trigger: 'item',
- },
- series: [
- {
- name: '访问来源',
- type: 'pie',
- radius: '50%',
- emphasis: {
- itemStyle: {
- shadowBlur: 10,
- shadowOffsetX: 0,
- shadowColor: 'rgba(0, 0, 0, 0.5)',
- },
- },
- },
- ],
- }
- const classPie = {
- tooltip: {
- trigger: 'item',
- },
- legend: {
- type: 'scroll',
- orient: 'vertical',
- left: 20,
- top: 20,
- formatter: function(name) {
- return echarts.format.truncateText(name, 80, '14px Microsoft Yahei', '…')
- },
- },
- series: [
- {
- name: '访问来源',
- type: 'pie',
- radius: '50%',
- label: {
- normal: {
- show: false,
- },
- },
- emphasis: {
- label: {
- show: true,
- fontSize: '16',
- },
- },
- labelLine: {
- normal: {
- show: false,
- },
- },
- data: [],
- },
- ],
- }
- const knowledgeBar = {
- tooltip: {
- trigger: 'axis',
- axisPointer: {
- // 坐标轴指示器,坐标轴触发有效
- type: 'shadow', // 默认为直线,可选为:'line' | 'shadow'
- },
- },
- grid: {
- top: '20%',
- left: '3%',
- right: '4%',
- bottom: '2%',
- containLabel: true,
- },
- xAxis: {
- type: 'category',
- axisTick: {
- show: false,
- },
- axisLabel: {
- interval: 0,
- fontSize: 14,
- },
- axisLine: {
- lineStyle: {
- color: '#5475c8',
- },
- },
- },
- yAxis: { type: 'value' },
- series: [
- {
- name: '投稿数量',
- type: 'bar',
- barWidth: 8,
- barGap: 0,
- label: {
- normal: {
- show: false,
- position: 'insideRight',
- },
- },
- itemStyle: {
- normal: {
- color: '#5c9bd5',
- },
- },
- },
- {
- name: '投稿数量',
- type: 'bar',
- barWidth: 8,
- tooltip: {
- show: false,
- },
- label: {
- normal: {
- show: false,
- position: 'insideRight',
- },
- },
- itemStyle: {
- normal: {
- color: '#3b6488',
- },
- },
- },
- {
- name: '投稿数量',
- type: 'pictorialBar', // 长方体顶部四边形
- symbol: 'diamond',
- symbolRotate: 0,
- symbolSize: ['16', '10'],
- symbolOffset: ['0', '-5'],
- symbolPosition: 'end',
- tooltip: {
- show: false,
- },
- label: {
- normal: {
- show: false,
- position: 'insideRight',
- },
- },
- itemStyle: {
- normal: {
- color: '#548bb9',
- },
- },
- },
- ],
- }
- const knowledgeClassPie = {
- tooltip: {
- trigger: 'item',
- formatter: '{a} <br/>{b}: {c}',
- },
- legend: {
- type: 'scroll',
- orient: 'vertical',
- left: 20,
- top: 20,
- formatter: function(name) {
- return echarts.format.truncateText(name, 80, '14px Microsoft Yahei', '…')
- },
- },
- series: [
- {
- name: '访问来源',
- type: 'pie',
- radius: ['30%', '55%'],
- avoidLabelOverlap: false,
- label: {
- show: false,
- position: 'center',
- },
- emphasis: {
- label: {
- show: true,
- fontSize: '20',
- fontWeight: 'bold',
- },
- },
- labelLine: {
- show: false,
- },
- },
- ],
- }
- const knowledgeSourcePie = {
- tooltip: {
- trigger: 'item',
- },
- legend: {
- type: 'scroll',
- orient: 'vertical',
- left: 20,
- top: 20,
- },
- series: [
- {
- name: '访问来源',
- type: 'pie',
- radius: '50%',
- label: {
- normal: {
- show: false,
- },
- },
- emphasis: {
- label: {
- show: true,
- fontSize: '16',
- },
- },
- labelLine: {
- normal: {
- show: false,
- },
- },
- data: [],
- },
- ],
- }
- export default {
- name: 'KmStatisticsGraphical',
- metaInfo: {
- title: '统计分析',
- },
- components,
- data() {
- return {
- visitBar,
- deptVisitPie,
- classPie,
- knowledgeBar,
- knowledgeClassPie,
- knowledgeSourcePie,
- graphicalData: {},
- visitTrend: {},
- knowledgeTrend: {},
- iconStyle: { fontSize: '26px', color: '#fff' },
- }
- },
- mounted() {
- this.queryStatisticsAnalysis()
- // 访问趋势图
- this.queryVisitTrend()
- // 知识投稿趋势图
- this.queryKnowledgeContribute()
- this.queryKnowledgeDeptSource()
- //
- this.queryDeptVisit()
- this.queryclassPie()
- this.queryClassifyVisit()
- },
- methods: {
- queryStatisticsAnalysis() {
- KmKnowledageService.getStatisticsAnalysis().then((res) => {
- this.graphicalData = res.data
- })
- },
- queryVisitTrend() {
- KmKnowledageService.getVisitTrend().then((res) => {
- this.visitBar.xAxis.data = res.data.xAxisData
- this.visitBar.series[0].data = res.data.data
- this.$refs.visitBar.refresh()
- })
- },
- // 知识投稿趋势图
- queryKnowledgeContribute() {
- KmKnowledageService.getKnowledgeContribute().then((res) => {
- this.knowledgeBar.xAxis.data = res.data.xAxisData
- this.knowledgeBar.series[0].data = res.data.data
- this.knowledgeBar.series[1].data = res.data.data
- this.knowledgeBar.series[2].data = res.data.data
- this.$refs.knowledgeBar.refresh()
- })
- },
- queryKnowledgeDeptSource() {
- KmKnowledageService.getKnowledgeDeptSource().then((res) => {
- const json = res.data.data
- this.knowledgeClassPie.legend.data = Object.keys(json)
- const deptArr = []
- for (var i in json) {
- deptArr.push({ value: json[i], name: i })
- }
- this.knowledgeClassPie.series[0].data = deptArr
- this.$refs.knowledgeClassPie.refresh()
- })
- },
- queryDeptVisit() {
- KmKnowledageService.getDeptVisit().then((res) => {
- const json = res.data.data
- const deptArr = []
- for (var i in json) {
- deptArr.push({ value: json[i], name: i })
- }
- this.deptVisitPie.series[0].data = deptArr
- this.$refs.deptVisitPie.refresh()
- })
- },
- queryclassPie() {
- KmKnowledageService.getClassPie().then((res) => {
- const json = res.data.data
- const deptArr = []
- for (var i in json) {
- deptArr.push({ value: json[i], name: i })
- }
- this.classPie.series[0].data = deptArr
- })
- },
- queryClassifyVisit() {
- KmKnowledageService.getClassifyVisit().then((res) => {
- const json = res.data.data
- const deptArr = []
- for (var i in json) {
- deptArr.push({ value: json[i], name: i })
- }
- this.knowledgeSourcePie.series[0].data = deptArr
- })
- },
- },
- }
- </script>
- <style module lang="scss">
- @use '@/common/design' as *;
- .statistics {
- overflow: hidden;
- background-color: $white;
- ul {
- padding-left: 0;
- li {
- position: relative;
- display: flex;
- float: left;
- width: calc(20% - 60px);
- padding-top: 20px;
- margin-right: 30px;
- margin-left: 30px;
- color: $text-color;
- text-align: center;
- list-style: none;
- div {
- padding-left: 10px;
- }
- img {
- width: 58px;
- height: 58px;
- }
- p {
- margin-bottom: 12px;
- text-align: left;
- span {
- padding-left: 10px;
- }
- }
- .all {
- span {
- color: $blue-7;
- }
- }
- .new {
- font-weight: bold;
- span {
- font-weight: bold;
- color: $red-7;
- }
- }
- }
- }
- }
- .graphical {
- padding-top: 20px;
- .box {
- padding-right: 20px;
- }
- .fontslot {
- :global(.anticon-fund) {
- margin-right: 10px;
- color: $blue-6;
- }
- }
- .bar {
- width: 100%;
- }
- .bars {
- width: 100%;
- }
- .pie {
- width: 100%;
- }
- .marginwidth {
- margin-top: 20px;
- }
- .piecenter {
- width: 100%;
- }
- }
- </style>
|