left.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  1. <template>
  2. <div>
  3. <CusModule title="设备类型统计">
  4. <Pie3d :pieData="pieData"/>
  5. </CusModule>
  6. <CusModule class="module-top" title="设备状态分析">
  7. <div class="dev-top">
  8. <div class="dev-ttl">
  9. <div class="txt-sml txt-clr">设备总数</div>
  10. <div class="num">
  11. <span v-for="value, index in countFormat(deviceTotal, 6)" :key="index">{{ value }}</span>
  12. </div>
  13. </div>
  14. </div>
  15. <div class="dev-flx">
  16. <div v-for="i in equipList" class="dev-itm" :key="i.name" :style="{ backgroundImage: `url(${i.image})` }">
  17. <div class="val">
  18. <span class="num">{{ i.value }}</span><span class="unit">{{ i.unit }}</span>
  19. </div>
  20. <div class="pct">
  21. {{ i.pct }}<span class="unit">%</span>
  22. </div>
  23. <div class="name">
  24. {{ i.name }}
  25. </div>
  26. </div>
  27. </div>
  28. </CusModule>
  29. <CusModule class="module-top" title="处置状态">
  30. <div class="dev-flex">
  31. <div class="dev-item" v-for="item in deal" :key="item.name">
  32. <div class="percent">{{ item.percent }} %</div>
  33. <div class="details">
  34. <div class="alarm">
  35. {{ item.name }}:<span class="alarm-count">{{ item.value }}次</span>
  36. </div>
  37. <div>
  38. <span class="value">{{ item.dealValue }}</span><span class="unit">次</span>
  39. </div>
  40. <div>已处理</div>
  41. </div>
  42. </div>
  43. </div>
  44. </CusModule>
  45. </div>
  46. </template>
  47. <script>
  48. import CusModule from '../components/CusModule.vue';
  49. import BaseChart from '@/components/BaseChart/index.vue'
  50. import Pie3d from './pie3d.vue'
  51. import {mapState} from 'vuex';
  52. import {listDeviceStatus, listDeviceType} from "@/api/device/device";
  53. import {fetchCntHandled} from "@/api/alarm/alarm-info";
  54. import {DateTool} from "@/utils/DateTool";
  55. export default {
  56. name: 'DeviceLeft',
  57. data() {
  58. return {
  59. pieData: [],
  60. deviceTotal: 0,
  61. equipList: [
  62. {
  63. name: "在线设备",
  64. value: 530,
  65. unit: "次",
  66. image: require("@/assets/images/device/l2-item1_bg.png"),
  67. },
  68. // {
  69. // name: "故障设备",
  70. // value: 12,
  71. // pct: 30,
  72. // unit: "次",
  73. // image: require("@/assets/images/device/l2-item2_bg.png"),
  74. // },
  75. {
  76. name: "离线设备",
  77. value: 6,
  78. unit: "次",
  79. image: require("@/assets/images/device/l2-item3_bg.png"),
  80. },
  81. ],
  82. deal: [
  83. {
  84. name: '今日报警',
  85. percent: 70,
  86. value: 10,
  87. dealValue: 7
  88. },
  89. {
  90. name: '本月报警',
  91. percent: 80,
  92. value: 300,
  93. dealValue: 240
  94. },
  95. ]
  96. };
  97. },
  98. components: {
  99. CusModule,
  100. BaseChart,
  101. Pie3d
  102. },
  103. computed: {
  104. ...mapState('userState', ['areaType']),
  105. },
  106. watch: {
  107. areaType() {
  108. this.getDeviceData()
  109. }
  110. },
  111. mounted() {
  112. this.getDeviceData()
  113. this.timer && clearInterval(this.timer)
  114. this.timer = setInterval(() => {
  115. this.getDeviceData()
  116. }, 60000 * 3)
  117. },
  118. beforeDestroy() {
  119. this.timer && clearInterval(this.timer)
  120. },
  121. methods: {
  122. //字符串转数组 总数
  123. countFormat(val, total = 0) {
  124. let str = String(val);
  125. let numArr = str.split("");
  126. if (total === 0) return numArr;
  127. let c = numArr.length <= total && total - numArr.length;
  128. let arr = [];
  129. if (c || c === 0) {
  130. for (let i = 0; i < c; i++) {
  131. numArr.unshift("0");
  132. }
  133. return numArr;
  134. } else {
  135. for (let i = 0; i < total; i++) {
  136. arr.push("9");
  137. }
  138. return arr;
  139. }
  140. },
  141. getDeviceData() {
  142. this.cntListDeviceType()
  143. this.cntListDeviceStatus()
  144. this.getCntHandled()
  145. },
  146. async cntListDeviceType() {
  147. const {data} = await listDeviceType({
  148. areaCode: this.areaType
  149. })
  150. this.pieData = data.map(item => ({
  151. name: item.typeName || '其他',
  152. value: item.total
  153. }))
  154. },
  155. async cntListDeviceStatus() {
  156. const {data} = await listDeviceStatus({
  157. areaCode: this.areaType
  158. })
  159. const {
  160. total,
  161. onlineCount
  162. } = data
  163. const [online, offline] = this.equipList
  164. this.deviceTotal = total
  165. const onlinePct = (onlineCount / total * 100).toFixed(1)
  166. online.pct = onlinePct
  167. offline.pct = (100 - onlinePct).toFixed(1)
  168. },
  169. async getCntHandled() {
  170. const {data: thisday = {}} = await fetchCntHandled({
  171. areaCode: this.areaType,
  172. startRecTime: DateTool.now()
  173. })
  174. const {data: thisMonth = {}} = await fetchCntHandled({
  175. areaCode: this.areaType,
  176. startRecTime: DateTool.thisMonth()
  177. })
  178. const [thisDayData, thisMonthData] = this.deal
  179. thisMonthData.value = thisMonth.cnt || 0
  180. thisMonthData.dealValue = thisMonth.handledCnt || 0
  181. thisMonthData.percent = thisMonthData.value && (thisMonthData.dealValue / thisMonthData.value * 100).toFixed(2)
  182. thisDayData.value = thisday.cnt || 0
  183. thisDayData.dealValue = thisday.handledCnt || 0
  184. thisDayData.percent = thisDayData.value && (thisDayData.dealValue / thisDayData.value * 100).toFixed(2)
  185. this.deal = [thisDayData, thisMonthData]
  186. },
  187. }
  188. }
  189. </script>
  190. <style lang='scss' scoped>
  191. @import url("../index.scss");
  192. .dev-top {
  193. height: 66px;
  194. background-image: url('~@/assets/images/device/l2-top_bg.png');
  195. background-position: center;
  196. background-repeat: no-repeat;
  197. text-align: center;
  198. padding-top: 5px;
  199. margin-top: 2px;
  200. .dev-ttl {
  201. .txt-sml {
  202. margin-top: 12px;
  203. color: #B3E3E8;
  204. font-size: 12px;
  205. }
  206. .num {
  207. margin-top: 2px;
  208. font-size: 16px;
  209. font-weight: bold;
  210. letter-spacing: 16px;
  211. margin-left: 16px;
  212. }
  213. }
  214. }
  215. .dev-flx {
  216. display: flex;
  217. justify-content: space-around;
  218. margin-top: 4px;
  219. .dev-itm {
  220. width: 103px;
  221. height: 150px;
  222. position: relative;
  223. .val {
  224. width: 100%;
  225. text-align: center;
  226. position: absolute;
  227. bottom: 82px;
  228. color: #07e3f9;
  229. }
  230. .pct {
  231. width: 100%;
  232. text-align: center;
  233. position: absolute;
  234. bottom: 50px;
  235. }
  236. .name {
  237. width: 100%;
  238. text-align: center;
  239. position: absolute;
  240. color: #B3E3E8;
  241. font-size: 14px;
  242. bottom: 18px;
  243. }
  244. .num {
  245. font-size: 18px;
  246. font-weight: bold;
  247. }
  248. }
  249. }
  250. .dev-flex {
  251. display: flex;
  252. justify-content: space-around;
  253. margin-top: 3px;
  254. .dev-item {
  255. width: 157px;
  256. height: 235px;
  257. text-align: center;
  258. color: #B3E3E8;
  259. font-size: 12px;
  260. background: url("~@/assets/images/device/l3-item_bg.png");
  261. background-position: center;
  262. background-repeat: no-repeat;
  263. .percent {
  264. margin-top: 45px;
  265. font-size: 18px;
  266. }
  267. .details {
  268. margin-top: 40px;
  269. font-size: 14px;
  270. .alarm {
  271. margin-bottom: 15px;
  272. font-size: 14px;
  273. .alarm-count {
  274. color: #E15050;
  275. }
  276. }
  277. .value {
  278. color: #07e3f9;
  279. font-size: 18px;
  280. }
  281. }
  282. }
  283. }
  284. </style>