numberStatistics.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  1. <!--数量统计-->
  2. <template>
  3. <div class="iotHome-numberStatistics">
  4. <div class="number-big-box">
  5. <img src="@/assets/ZDimages/iotDevice/home_iot_icon.png">
  6. <div>
  7. <p>{{newData.iotDeviceCount}}</p>
  8. <p>物联设备</p>
  9. </div>
  10. <p class="border-right-p"></p>
  11. </div>
  12. <div class="number-big-box ">
  13. <img class="right-icon" src="@/assets/ZDimages/iotDevice/home_hardware_icon.png">
  14. <div>
  15. <p>{{newData.hardwareCount}}</p>
  16. <p>硬件设备</p>
  17. </div>
  18. <p class="border-right-p"></p>
  19. </div>
  20. <div class="statistics-box">
  21. <div id="number-statistics-box">
  22. </div>
  23. <div class="button-box">
  24. <div class="button-for-box" :class="checkValue === index ? 'checkValue':''"
  25. v-for="(item,index) in newList" :key="index">
  26. <span v-if="checkValue === index" class="iconfont iconfont-a icon-xuanzhong2"></span>
  27. <span v-if="checkValue !== index" class="iconfont iconfont-b icon-danxuankuang"></span>
  28. <p>{{item.name}}:</p>
  29. <p>{{item.value}}%</p>
  30. </div>
  31. </div>
  32. </div>
  33. </div>
  34. </template>
  35. <script>
  36. import { iotStatisticsDevices } from "@/api/iotDevice/index";
  37. export default {
  38. name: 'numberStatistics',
  39. data(){
  40. return{
  41. newData:{
  42. iotDeviceCount:'',
  43. hardwareCount:'',
  44. },
  45. newList:[
  46. { name:'在线设备',value:'' },{ name:'离线设备',value:'' },
  47. ],
  48. checkValue:0,
  49. }
  50. },
  51. created(){
  52. },
  53. mounted(){
  54. this.iotStatisticsDevices();
  55. },
  56. methods:{
  57. iotStatisticsDevices(){
  58. iotStatisticsDevices({}).then(response => {
  59. this.$set(this,'newData',{
  60. iotDeviceCount:response.data.iotDeviceCount,
  61. hardwareCount:response.data.hardwareCount,
  62. });
  63. this.$set(this,'newList',[
  64. { name:'在线设备',value:response.data.onlineRate },{ name:'离线设备',value:response.data.offlineRate },
  65. ]);
  66. this.$nextTick(()=>{
  67. this.checkButton(this.newList[0].value,this.newList[0].name,0);
  68. })
  69. })
  70. },
  71. checkButton(num,text,index){
  72. this.$set(this,'checkValue',index);
  73. this.eChartsDraw(num,text);
  74. },
  75. eChartsDraw(num,text){
  76. let myChart = this.$echarts.init(document.getElementById('number-statistics-box'));
  77. let Green = {
  78. x: 0,
  79. y: 0,
  80. x2: 0,
  81. y2: 1,
  82. colorStops: [{
  83. offset: 0,
  84. color: '#99da69' // 0% 处的颜色
  85. }, {
  86. offset: 1,
  87. color: '#01babc' // 100% 处的颜色
  88. }],
  89. globalCoord: false // 缺省为 false
  90. };
  91. let option = {
  92. backgroundColor: '#fff',
  93. title: {
  94. text: num +'%',
  95. subtext: text,
  96. x: 'center',
  97. y: 36,
  98. textStyle: {
  99. fontSize:14,
  100. fontWeight:'normal',
  101. color: ['#67828c']
  102. },
  103. subtextStyle: {
  104. color: '#67828c',
  105. fontSize: 12,
  106. align: 'center',
  107. }
  108. },
  109. series: [{
  110. //渐变圆环
  111. name: "",
  112. type: "pie",
  113. radius: ["60%", "75%"],
  114. startAngle: 180,
  115. hoverAnimation: false,
  116. avoidLabelOverlap: true,
  117. z: 0,
  118. zlevel: 0,
  119. label: {
  120. show: false,
  121. normal: {show: false}
  122. },
  123. data: [{
  124. value: 0,
  125. name: "",
  126. itemStyle: {
  127. normal: {
  128. color: Green
  129. }
  130. }
  131. }]
  132. },
  133. {
  134. //仪表盘样式
  135. name: "",
  136. type: "gauge",
  137. radius: "75%",
  138. startAngle: 310,
  139. clockwise:true,
  140. splitNumber: 50,
  141. hoverAnimation: true,
  142. axisTick: {
  143. show: false
  144. },
  145. splitLine: {
  146. length: 8,
  147. lineStyle: {
  148. width: 1,
  149. color: "#fff"
  150. }
  151. },
  152. axisLabel: {
  153. show: false
  154. },
  155. pointer: {
  156. show: false
  157. },
  158. axisLine: {
  159. lineStyle: {
  160. opacity: 0
  161. }
  162. },
  163. detail: {
  164. show: false
  165. },
  166. data: [{
  167. value: num,
  168. name: ""
  169. }]
  170. },
  171. {
  172. //进度圆环
  173. name: 'Line 1',
  174. type: 'pie',
  175. startAngle: 180,
  176. clockWise: true,
  177. radius:['80%','85%'],
  178. itemStyle: {
  179. normal: {
  180. label: {
  181. show: true
  182. },
  183. labelLine: {
  184. show: false
  185. },
  186. }
  187. },
  188. hoverAnimation: false,
  189. data: [{
  190. value: num ,
  191. itemStyle: {
  192. normal: {
  193. color: '#20da97'
  194. }
  195. }
  196. },{//画中间的图标
  197. name: "",
  198. value: 0,
  199. label: {
  200. position:'inside',
  201. width: 16,
  202. height: 16,
  203. borderRadius: 20,
  204. padding: 11
  205. }
  206. }, {
  207. value: 100 - num ,
  208. name: 'invisible',
  209. itemStyle: {
  210. normal: {
  211. color: 'transparent', //未完成的圆环的颜色
  212. label: {
  213. show: false
  214. },
  215. labelLine: {
  216. show: false
  217. }
  218. }
  219. }
  220. }
  221. ]
  222. }
  223. ]
  224. };
  225. myChart.setOption(option);
  226. },
  227. },
  228. }
  229. </script>
  230. <style scoped lang="scss">
  231. .iotHome-numberStatistics{
  232. display: flex;
  233. .number-big-box{
  234. display: flex;
  235. img{
  236. width:60px;
  237. height:60px;
  238. margin:30px 40px 30px 80px;
  239. }
  240. .right-icon{
  241. width:50px;
  242. height:50px;
  243. margin:40px 40px 30px 80px;
  244. }
  245. div{
  246. width:200px;
  247. margin-right:60px;
  248. p{
  249. line-height:30px;
  250. font-size:18px;
  251. text-align: center;
  252. font-weight:700;
  253. color:#666;
  254. }
  255. p:nth-child(1){
  256. margin-top:30px;
  257. }
  258. p:nth-child(2){
  259. }
  260. }
  261. .border-right-p{
  262. width:1px;
  263. height:60px;
  264. margin:30px 0;
  265. background-color: #999;
  266. }
  267. }
  268. .statistics-box{
  269. flex:1;
  270. display: flex;
  271. #number-statistics-box{
  272. /*flex:1;*/
  273. height:120px;
  274. width:200px;
  275. margin-left:100px;
  276. }
  277. .button-box{
  278. margin-left:60px;
  279. padding:20px 0 0;
  280. .checkValue{
  281. p{
  282. /*color:#20DA97!important;*/
  283. }
  284. }
  285. .button-for-box{
  286. display: flex;
  287. p{
  288. line-height:40px;
  289. color:#999;
  290. }
  291. img{
  292. width:20px;
  293. height:20px;
  294. margin:10px;
  295. }
  296. .iconfont-a{
  297. font-size:22px;
  298. color:#20DA97;
  299. margin:10px;
  300. }
  301. .iconfont-b{
  302. font-size:23px;
  303. color:#999;
  304. margin:8px 9px;
  305. }
  306. }
  307. }
  308. }
  309. }
  310. </style>