leftButtom.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. <template>
  2. <div class="cointan">
  3. <div class="title1">
  4. <img src="../assets/index/title_icon.png" style="width:22px;height:22px;float: left;">
  5. <div style="margin-left:25px;line-height: 22px;">近30日出归人员统计</div>
  6. </div>
  7. <!-- 柱状图 -->
  8. <div class="chart" ref="chart"></div>
  9. </div>
  10. </template>
  11. <script>
  12. export default {
  13. name: 'leftButtom',
  14. data() {
  15. return {
  16. tongTime:[],//统计的横坐标时间
  17. tongNum:[],//出归人数
  18. build:'',//楼栋
  19. token:'',//请求头token
  20. }
  21. },
  22. props: {
  23. msg: String
  24. },
  25. created(){
  26. },
  27. mounted(){
  28. this.token=sessionStorage.getItem('token')
  29. this.build=sessionStorage.getItem('build')
  30. this.getchugui()
  31. this.t3 = setInterval(function() {
  32. this.getchugui()
  33. }, 43200000);
  34. },
  35. beforeDestroy() {
  36. // 页面关闭清除定时器
  37. clearInterval(this.t3)
  38. },
  39. methods:{
  40. //近30天出归人员统计
  41. getchugui(){
  42. this.tongTime=[]
  43. this.tongNum=[]
  44. this.$axios.get('/auto/face-recognition/statistics?build='+this.build.split(",")[0]+'-'+this.build.split(",")[1],
  45. {
  46. headers: {
  47. "token": this.token,
  48. },
  49. }
  50. ).then(res => {
  51. if (res.data.success) {
  52. var shuzu=(res.data.data).reverse()
  53. // 横坐标时间
  54. shuzu.forEach(data => {
  55. this.tongTime.push(data.date.slice(5,10))
  56. })
  57. //纵坐标出归人数
  58. shuzu.forEach(data => {
  59. this.tongNum.push(data.count)
  60. })
  61. this.getEchartData()
  62. }
  63. })
  64. },
  65. // 30日出归人员
  66. getEchartData() {
  67. let _this = this;
  68. const chart = this.$refs.chart;
  69. var option = null;
  70. const myChart = this.$echarts.init(chart);
  71. option = {
  72. color: ['#00DAD8', '#00FF96'],
  73. title: {
  74. text: ''
  75. },
  76. tooltip: {
  77. trigger: 'axis',
  78. axisPointer: {
  79. type: 'cross',
  80. label: {
  81. backgroundColor: '#0FEBFF'
  82. }
  83. }
  84. },
  85. grid: {
  86. left: '1%',
  87. right: '8%',
  88. bottom: '2%',
  89. containLabel: true
  90. },
  91. xAxis: [
  92. {
  93. name:'日',
  94. nameTextStyle: {
  95. color: "#FFFFFF",
  96. },
  97. axisLabel: {
  98. show: true,
  99. fontSize: 12,
  100. color: "#FFFFFF",//人数的颜色
  101. },
  102. axisLine: {
  103. show: true,
  104. lineStyle: {
  105. color: "#2E3F44",
  106. },
  107. },
  108. type: 'category',
  109. data: this.tongTime
  110. }
  111. ],
  112. yAxis: [
  113. {
  114. name:'人',
  115. nameTextStyle: {
  116. color: "#FFFFFF",
  117. },
  118. axisLabel: {
  119. show: true,
  120. fontSize: 12,
  121. color: "#FFFFFF",
  122. },
  123. axisLine: {
  124. show: false,
  125. lineStyle: {
  126. color: "#FFFFFF",
  127. },
  128. },
  129. splitLine: {
  130. show: true,
  131. lineStyle: {
  132. type: [5, 10],
  133. dashOffset: 5,
  134. color:'#606060'
  135. }
  136. },
  137. type: 'value'
  138. }
  139. ],
  140. series: [
  141. {
  142. name: '人员统计',
  143. type: 'bar',
  144. barWidth: "3",
  145. data: this.tongNum
  146. },
  147. ]
  148. };
  149. myChart.setOption(option);
  150. myChart.off("click");
  151. myChart.on("click", function (params) {
  152. // console.log(params);
  153. _this.$emit("openPop");
  154. });
  155. window.addEventListener("resize", function () {
  156. myChart.resize();
  157. });
  158. this.$on("hook:destroyed", () => {
  159. window.removeEventListener("resize", function () {
  160. chart.resize();
  161. });
  162. });
  163. return option;
  164. },
  165. }
  166. }
  167. </script>
  168. <!-- Add "scoped" attribute to limit CSS to this component only -->
  169. <style scoped lang="scss">
  170. .cointan{
  171. width: 428px;
  172. height: 349px;
  173. background-image: url('../assets/leftBottom/background.png');
  174. background-size: 100%;
  175. }
  176. .title1{
  177. position: absolute;
  178. margin: 9px 0 0 10px;
  179. font-size: 20px;
  180. font-family : '优设标题黑';
  181. color: rgba(255, 255, 255, 1);
  182. font-weight: 400;
  183. }
  184. // 柱状图
  185. .chart{
  186. position: absolute;
  187. margin: 50px 0 0 20px;
  188. width: 390px;
  189. height: 278px;
  190. }
  191. </style>