km-statistics-graphical.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607
  1. <template>
  2. <div>
  3. <div :class="$style.statistics">
  4. <ul>
  5. <li>
  6. <img src="../images/statistics-zsk.png" alt="" />
  7. <div>
  8. <p :class="$style.all"
  9. >知识库<span> {{ sdGet('graphicalData.knowledage?.all') || 0 }}</span></p
  10. >
  11. <p :class="$style.new"
  12. >本月上新<span>{{ sdGet('graphicalData.knowledage?.thisMonth') || 0 }}</span></p
  13. >
  14. </div>
  15. </li>
  16. <li>
  17. <img src="../images/statistics-zsdt.png" alt="" />
  18. <div>
  19. <p :class="$style.all"
  20. >知识地图<span>{{ sdGet('graphicalData.kmap?.all') || 0 }}</span></p
  21. >
  22. <p :class="$style.new"
  23. >本月上新<span>{{ sdGet('graphicalData.kmap?.thisMonth') || 0 }}</span></p
  24. >
  25. </div>
  26. </li>
  27. <li
  28. ><img src="../images/statistics-yzzs.png" alt="" />
  29. <div>
  30. <p :class="$style.all"
  31. >原子知识<span>{{ sdGet('graphicalData.atom?.all') || 0 }}</span></p
  32. ><p :class="$style.new"
  33. >本月上新<span>{{ sdGet('graphicalData.atom?.thisMonth') || 0 }}</span></p
  34. >
  35. </div>
  36. </li>
  37. <li
  38. ><img src="../images/statistics-fwcs.png" alt="" />
  39. <div>
  40. <p :class="$style.all"
  41. >访问次数<span>{{ sdGet('graphicalData.visits?.all') || 0 }}</span></p
  42. >
  43. <p :class="$style.new"
  44. >本月访问<span>{{ sdGet('graphicalData.visits?.thisMonth') || 0 }}</span></p
  45. >
  46. </div>
  47. </li>
  48. <li
  49. ><img src="../images/statistics-zjhd.png" alt="" />
  50. <div>
  51. <p :class="$style.all"
  52. >专家问答<span>{{ sdGet('graphicalData.expert?.all') || 0 }}</span></p
  53. >
  54. <p :class="$style.new"
  55. >本月上新<span>{{ sdGet('graphicalData.expert?.thisMonth') || 0 }}</span></p
  56. >
  57. </div>
  58. </li>
  59. </ul>
  60. </div>
  61. <div :class="$style.graphical">
  62. <a-row>
  63. <a-col :span="12">
  64. <div :class="$style.box">
  65. <a-card :bordered="false" :class="$style.cardBody">
  66. <div slot="title" :class="$style.fontslot"><a-icon type="fund" />访问趋势分析</div>
  67. <div :class="$style.echartclass">
  68. <sd-echart ref="visitBar" :class="$style.bar" :options="visitBar" autoresize />
  69. </div>
  70. </a-card>
  71. </div>
  72. </a-col>
  73. <a-col :span="12">
  74. <a-card :bordered="false" :class="$style.cardBody">
  75. <div slot="title" :class="$style.fontslot"><a-icon type="fund" />各部门访问量分布</div>
  76. <div :class="$style.echartclass">
  77. <sd-echart
  78. ref="deptVisitPie"
  79. :class="$style.piecenter"
  80. :options="deptVisitPie"
  81. autoresize
  82. />
  83. </div>
  84. </a-card>
  85. </a-col>
  86. </a-row>
  87. <a-row :class="$style.marginwidth">
  88. <a-col :span="12">
  89. <div :class="$style.box">
  90. <a-card :bordered="false" :class="$style.cardBody">
  91. <div slot="title" :class="$style.fontslot"
  92. ><a-icon type="fund" />各分类访问量分布</div
  93. >
  94. <div :class="$style.echartclass">
  95. <sd-echart
  96. ref="classPie"
  97. :class="$style.piecenter"
  98. :options="classPie"
  99. autoresize
  100. />
  101. </div>
  102. </a-card>
  103. </div>
  104. </a-col>
  105. <a-col :span="12">
  106. <a-card :bordered="false" :class="$style.cardBody">
  107. <div slot="title" :class="$style.fontslot"><a-icon type="fund" />知识投稿趋势</div>
  108. <div :class="$style.echartclass">
  109. <sd-echart
  110. ref="knowledgeBar"
  111. :class="$style.bars"
  112. :options="knowledgeBar"
  113. autoresize
  114. />
  115. </div>
  116. </a-card>
  117. </a-col>
  118. </a-row>
  119. <a-row :class="$style.marginwidth">
  120. <a-col :span="12">
  121. <div :class="$style.box">
  122. <a-card :bordered="false" :class="$style.cardBody">
  123. <div slot="title" :class="$style.fontslot"
  124. ><a-icon type="fund" />知识投稿部门来源分布</div
  125. >
  126. <div :class="$style.echartclass">
  127. <sd-echart
  128. ref="knowledgeClassPie"
  129. :class="$style.piecenter"
  130. :options="knowledgeClassPie"
  131. autoresize
  132. />
  133. </div>
  134. </a-card>
  135. </div>
  136. </a-col>
  137. <a-col :span="12">
  138. <a-card :bordered="false" :class="$style.cardBody">
  139. <div slot="title" :class="$style.fontslot"
  140. ><a-icon type="fund" />知识投稿分类来源分布</div
  141. >
  142. <div :class="$style.echartclass">
  143. <sd-echart
  144. ref="knowledgeSourcePie"
  145. :class="$style.piecenter"
  146. :options="knowledgeSourcePie"
  147. autoresize
  148. />
  149. </div>
  150. </a-card>
  151. </a-col>
  152. </a-row>
  153. </div>
  154. </div>
  155. </template>
  156. <script>
  157. // 为了按需加载,下面的组件需要手工导入
  158. import 'echarts/lib/chart/pie'
  159. import 'echarts/lib/chart/pictorialBar'
  160. import 'echarts/lib/component/title'
  161. import 'echarts/lib/chart/bar'
  162. import 'echarts/lib/component/legend'
  163. import 'echarts/lib/component/legendScroll'
  164. import 'echarts/lib/component/tooltip'
  165. import KmKnowledageService from '../km-knowledage-service'
  166. import components from './_import-components/km-statistics-graphical-import'
  167. const echarts = require('echarts/lib/echarts')
  168. const visitBar = {
  169. tooltip: {
  170. trigger: 'axis',
  171. axisPointer: {
  172. // 坐标轴指示器,坐标轴触发有效
  173. type: 'shadow', // 默认为直线,可选为:'line' | 'shadow'
  174. },
  175. },
  176. xAxis: {
  177. type: 'category',
  178. axisTick: {
  179. alignWithLabel: true,
  180. },
  181. axisLabel: {
  182. rotate: 40,
  183. interval: 0,
  184. },
  185. },
  186. yAxis: {
  187. type: 'value',
  188. },
  189. series: [
  190. {
  191. name: '访问量',
  192. type: 'bar',
  193. barWidth: 8, // 固定柱子宽度
  194. },
  195. ],
  196. }
  197. const deptVisitPie = {
  198. tooltip: {
  199. trigger: 'item',
  200. },
  201. series: [
  202. {
  203. name: '访问来源',
  204. type: 'pie',
  205. radius: '50%',
  206. emphasis: {
  207. itemStyle: {
  208. shadowBlur: 10,
  209. shadowOffsetX: 0,
  210. shadowColor: 'rgba(0, 0, 0, 0.5)',
  211. },
  212. },
  213. },
  214. ],
  215. }
  216. const classPie = {
  217. tooltip: {
  218. trigger: 'item',
  219. },
  220. legend: {
  221. type: 'scroll',
  222. orient: 'vertical',
  223. left: 20,
  224. top: 20,
  225. formatter: function(name) {
  226. return echarts.format.truncateText(name, 80, '14px Microsoft Yahei', '…')
  227. },
  228. },
  229. series: [
  230. {
  231. name: '访问来源',
  232. type: 'pie',
  233. radius: '50%',
  234. label: {
  235. normal: {
  236. show: false,
  237. },
  238. },
  239. emphasis: {
  240. label: {
  241. show: true,
  242. fontSize: '16',
  243. },
  244. },
  245. labelLine: {
  246. normal: {
  247. show: false,
  248. },
  249. },
  250. data: [],
  251. },
  252. ],
  253. }
  254. const knowledgeBar = {
  255. tooltip: {
  256. trigger: 'axis',
  257. axisPointer: {
  258. // 坐标轴指示器,坐标轴触发有效
  259. type: 'shadow', // 默认为直线,可选为:'line' | 'shadow'
  260. },
  261. },
  262. grid: {
  263. top: '20%',
  264. left: '3%',
  265. right: '4%',
  266. bottom: '2%',
  267. containLabel: true,
  268. },
  269. xAxis: {
  270. type: 'category',
  271. axisTick: {
  272. show: false,
  273. },
  274. axisLabel: {
  275. interval: 0,
  276. fontSize: 14,
  277. },
  278. axisLine: {
  279. lineStyle: {
  280. color: '#5475c8',
  281. },
  282. },
  283. },
  284. yAxis: { type: 'value' },
  285. series: [
  286. {
  287. name: '投稿数量',
  288. type: 'bar',
  289. barWidth: 8,
  290. barGap: 0,
  291. label: {
  292. normal: {
  293. show: false,
  294. position: 'insideRight',
  295. },
  296. },
  297. itemStyle: {
  298. normal: {
  299. color: '#5c9bd5',
  300. },
  301. },
  302. },
  303. {
  304. name: '投稿数量',
  305. type: 'bar',
  306. barWidth: 8,
  307. tooltip: {
  308. show: false,
  309. },
  310. label: {
  311. normal: {
  312. show: false,
  313. position: 'insideRight',
  314. },
  315. },
  316. itemStyle: {
  317. normal: {
  318. color: '#3b6488',
  319. },
  320. },
  321. },
  322. {
  323. name: '投稿数量',
  324. type: 'pictorialBar', // 长方体顶部四边形
  325. symbol: 'diamond',
  326. symbolRotate: 0,
  327. symbolSize: ['16', '10'],
  328. symbolOffset: ['0', '-5'],
  329. symbolPosition: 'end',
  330. tooltip: {
  331. show: false,
  332. },
  333. label: {
  334. normal: {
  335. show: false,
  336. position: 'insideRight',
  337. },
  338. },
  339. itemStyle: {
  340. normal: {
  341. color: '#548bb9',
  342. },
  343. },
  344. },
  345. ],
  346. }
  347. const knowledgeClassPie = {
  348. tooltip: {
  349. trigger: 'item',
  350. formatter: '{a} <br/>{b}: {c}',
  351. },
  352. legend: {
  353. type: 'scroll',
  354. orient: 'vertical',
  355. left: 20,
  356. top: 20,
  357. formatter: function(name) {
  358. return echarts.format.truncateText(name, 80, '14px Microsoft Yahei', '…')
  359. },
  360. },
  361. series: [
  362. {
  363. name: '访问来源',
  364. type: 'pie',
  365. radius: ['30%', '55%'],
  366. avoidLabelOverlap: false,
  367. label: {
  368. show: false,
  369. position: 'center',
  370. },
  371. emphasis: {
  372. label: {
  373. show: true,
  374. fontSize: '20',
  375. fontWeight: 'bold',
  376. },
  377. },
  378. labelLine: {
  379. show: false,
  380. },
  381. },
  382. ],
  383. }
  384. const knowledgeSourcePie = {
  385. tooltip: {
  386. trigger: 'item',
  387. },
  388. legend: {
  389. type: 'scroll',
  390. orient: 'vertical',
  391. left: 20,
  392. top: 20,
  393. },
  394. series: [
  395. {
  396. name: '访问来源',
  397. type: 'pie',
  398. radius: '50%',
  399. label: {
  400. normal: {
  401. show: false,
  402. },
  403. },
  404. emphasis: {
  405. label: {
  406. show: true,
  407. fontSize: '16',
  408. },
  409. },
  410. labelLine: {
  411. normal: {
  412. show: false,
  413. },
  414. },
  415. data: [],
  416. },
  417. ],
  418. }
  419. export default {
  420. name: 'KmStatisticsGraphical',
  421. metaInfo: {
  422. title: '统计分析',
  423. },
  424. components,
  425. data() {
  426. return {
  427. visitBar,
  428. deptVisitPie,
  429. classPie,
  430. knowledgeBar,
  431. knowledgeClassPie,
  432. knowledgeSourcePie,
  433. graphicalData: {},
  434. visitTrend: {},
  435. knowledgeTrend: {},
  436. iconStyle: { fontSize: '26px', color: '#fff' },
  437. }
  438. },
  439. mounted() {
  440. this.queryStatisticsAnalysis()
  441. // 访问趋势图
  442. this.queryVisitTrend()
  443. // 知识投稿趋势图
  444. this.queryKnowledgeContribute()
  445. this.queryKnowledgeDeptSource()
  446. //
  447. this.queryDeptVisit()
  448. this.queryclassPie()
  449. this.queryClassifyVisit()
  450. },
  451. methods: {
  452. queryStatisticsAnalysis() {
  453. KmKnowledageService.getStatisticsAnalysis().then((res) => {
  454. this.graphicalData = res.data
  455. })
  456. },
  457. queryVisitTrend() {
  458. KmKnowledageService.getVisitTrend().then((res) => {
  459. this.visitBar.xAxis.data = res.data.xAxisData
  460. this.visitBar.series[0].data = res.data.data
  461. this.$refs.visitBar.refresh()
  462. })
  463. },
  464. // 知识投稿趋势图
  465. queryKnowledgeContribute() {
  466. KmKnowledageService.getKnowledgeContribute().then((res) => {
  467. this.knowledgeBar.xAxis.data = res.data.xAxisData
  468. this.knowledgeBar.series[0].data = res.data.data
  469. this.knowledgeBar.series[1].data = res.data.data
  470. this.knowledgeBar.series[2].data = res.data.data
  471. this.$refs.knowledgeBar.refresh()
  472. })
  473. },
  474. queryKnowledgeDeptSource() {
  475. KmKnowledageService.getKnowledgeDeptSource().then((res) => {
  476. const json = res.data.data
  477. this.knowledgeClassPie.legend.data = Object.keys(json)
  478. const deptArr = []
  479. for (var i in json) {
  480. deptArr.push({ value: json[i], name: i })
  481. }
  482. this.knowledgeClassPie.series[0].data = deptArr
  483. this.$refs.knowledgeClassPie.refresh()
  484. })
  485. },
  486. queryDeptVisit() {
  487. KmKnowledageService.getDeptVisit().then((res) => {
  488. const json = res.data.data
  489. const deptArr = []
  490. for (var i in json) {
  491. deptArr.push({ value: json[i], name: i })
  492. }
  493. this.deptVisitPie.series[0].data = deptArr
  494. this.$refs.deptVisitPie.refresh()
  495. })
  496. },
  497. queryclassPie() {
  498. KmKnowledageService.getClassPie().then((res) => {
  499. const json = res.data.data
  500. const deptArr = []
  501. for (var i in json) {
  502. deptArr.push({ value: json[i], name: i })
  503. }
  504. this.classPie.series[0].data = deptArr
  505. })
  506. },
  507. queryClassifyVisit() {
  508. KmKnowledageService.getClassifyVisit().then((res) => {
  509. const json = res.data.data
  510. const deptArr = []
  511. for (var i in json) {
  512. deptArr.push({ value: json[i], name: i })
  513. }
  514. this.knowledgeSourcePie.series[0].data = deptArr
  515. })
  516. },
  517. },
  518. }
  519. </script>
  520. <style module lang="scss">
  521. @use '@/common/design' as *;
  522. .statistics {
  523. overflow: hidden;
  524. background-color: $white;
  525. ul {
  526. padding-left: 0;
  527. li {
  528. position: relative;
  529. display: flex;
  530. float: left;
  531. width: calc(20% - 60px);
  532. padding-top: 20px;
  533. margin-right: 30px;
  534. margin-left: 30px;
  535. color: $text-color;
  536. text-align: center;
  537. list-style: none;
  538. div {
  539. padding-left: 10px;
  540. }
  541. img {
  542. width: 58px;
  543. height: 58px;
  544. }
  545. p {
  546. margin-bottom: 12px;
  547. text-align: left;
  548. span {
  549. padding-left: 10px;
  550. }
  551. }
  552. .all {
  553. span {
  554. color: $blue-7;
  555. }
  556. }
  557. .new {
  558. font-weight: bold;
  559. span {
  560. font-weight: bold;
  561. color: $red-7;
  562. }
  563. }
  564. }
  565. }
  566. }
  567. .graphical {
  568. padding-top: 20px;
  569. .box {
  570. padding-right: 20px;
  571. }
  572. .fontslot {
  573. :global(.anticon-fund) {
  574. margin-right: 10px;
  575. color: $blue-6;
  576. }
  577. }
  578. .bar {
  579. width: 100%;
  580. }
  581. .bars {
  582. width: 100%;
  583. }
  584. .pie {
  585. width: 100%;
  586. }
  587. .marginwidth {
  588. margin-top: 20px;
  589. }
  590. .piecenter {
  591. width: 100%;
  592. }
  593. }
  594. </style>