index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500
  1. <template>
  2. <div class="app-container" >
  3. <div id="main" >
  4. <el-row :gutter="10">
  5. <el-col :span="6">
  6. <div class="card_left">
  7. <el-card class="box-card card_left1 " v-loading="loading1 && loading2">
  8. <span class="h2">设备工况</span>
  9. <div class="contain">
  10. <index1 :resData="index1Data" style="width:100%;height:20vh" alt="饼图" />
  11. <div class="title-btn">异常设备数</div>
  12. <index2 :resData="index2Data" style="width:100%;height:24.5vh;" alt="柱状图" />
  13. </div>
  14. </el-card>
  15. <el-card class="box-card card_left2 mg10" v-loading="loading3">
  16. <span class="h2">报警处理</span>
  17. <div class="contain">
  18. <index3 :resData="index3Data" style="width:105%;height:calc(100vh - 55.5vh - 120px);margin-left:-2.5%;" alt="折线图" />
  19. </div>
  20. </el-card>
  21. </div>
  22. </el-col>
  23. <el-col :span="12">
  24. <div class="card_center">
  25. <el-card class="box-card card_center1" style="padding:0 !important">
  26. <div class="map" style="height:45vh">
  27. <iframe style="width:100%;height:100%;border:none;" src='https://www.thingjs.com/s/ef7ee6a73896c01bda77e679?params=105b0f77fd24654d4eebc434e9'></iframe>
  28. </div>
  29. </el-card>
  30. <el-card class="box-card card_center2 mg10">
  31. <div class="title">
  32. <span class="h2">实时告警信息</span>
  33. </div>
  34. <div class="contain">
  35. <el-table :data="index4Data" style="margin-top:10px" height="calc(100vh - 54vh - 120px)">
  36. <el-table-column label="告警时间" align="left" prop="alarmTime" show-overflow-tooltip />
  37. <el-table-column label="告警内容" align="left" prop="property" show-overflow-tooltip />
  38. <el-table-column label="设备名称" align="left" prop="deviceName" show-overflow-tooltip />
  39. <el-table-column label="设备编号" align="left" prop="deviceId" show-overflow-tooltip />
  40. <el-table-column label="设备类型" align="left" prop="deviceTypeName" show-overflow-tooltip />
  41. </el-table>
  42. </div>
  43. </el-card>
  44. </div>
  45. </el-col>
  46. <el-col :span="6">
  47. <div class="card_right">
  48. <el-card class="box-card card_right1" v-loading="loading4">
  49. <div class="title">
  50. <span class="h2">园区实时报警统计</span>
  51. </div>
  52. <div class="contain">
  53. <div id="total-squares">
  54. <div class="total-square" v-for="(item,index) in timeList" :key="index">{{item}}</div>
  55. <div class="title-btn">当前时间</div>
  56. </div>
  57. <index5 :resData="index5Data" style="width:100%;" alt="横状图" />
  58. </div>
  59. </el-card>
  60. <el-card class="box-card card_right2 mg10" v-loading="loading4">
  61. <div class="title">
  62. <span class="h2">隐患处理</span>
  63. </div>
  64. <div class="contain">
  65. <div>
  66. <ul id="pop">
  67. <li>
  68. <div>
  69. <p class="num-huan" style="color:#6F99FA">{{collectList.checkCount}}</p>
  70. <p class="des-huan">已处理</p>
  71. </div>
  72. </li>
  73. <li>
  74. <div>
  75. <p class="num-huan" style="color:#6F99FA">{{collectList.noCheckCount}}</p>
  76. <p class="des-huan">未处理</p>
  77. </div>
  78. </li>
  79. <li>
  80. <div>
  81. <p class="num-huan" style="color:#6F99FA">{{Number((collectList.checkRadio)*100).toFixed(2)}}%</p>
  82. <p class="des-huan">处理率</p>
  83. </div>
  84. </li>
  85. <li>
  86. <div>
  87. <p class="num-huan" style="color:#6F99FA">{{collectList.total}}</p>
  88. <p class="des-huan">隐患总数</p>
  89. </div>
  90. </li>
  91. </ul>
  92. </div>
  93. <!-- <div class="title-btn" style="margin:10px auto">异常设备数</div> -->
  94. <div>
  95. <div>
  96. <el-table :data="index6Data" height="calc(100vh - 61.8vh - 120px)">
  97. <el-table-column label="序号" align="left" prop="id" />
  98. <el-table-column label="告警值" align="left" prop="property" show-overflow-tooltip />
  99. <el-table-column label="当前状态" align="left" prop="alarmStatus" >
  100. <template slot-scope="scope">
  101. <span :class="scope.row.alarmStatus == 1 ? 'processed' : 'unprocess'">{{ scope.row.alarmStatus == 1 ? '已处理': '未处理' }}</span>
  102. </template>
  103. </el-table-column>
  104. <el-table-column label="处理时间" align="left" prop="updateTime" show-overflow-tooltip />
  105. </el-table>
  106. </div>
  107. </div>
  108. </div>
  109. </el-card>
  110. </div>
  111. </el-col>
  112. </el-row>
  113. </div>
  114. </div>
  115. </template>
  116. <script>
  117. import { index1Api, index2Api, index3Api } from "@/api/business/index";
  118. import { getTbAlarm } from "@/api/business/OM/eventCenter";
  119. import { collectTbAlarm } from "@/api/business/OM/eventCenter";
  120. import { getThisDateBeforMonth, YearMonthDate } from "@/assets/js/dataFormate.js";
  121. import index1 from "./components/index/index1";
  122. import index2 from "./components/index/index2";
  123. import index3 from "./components/index/index3";
  124. import index5 from "./components/index/index5";
  125. // import index6 from "./components/index/index6";
  126. export default {
  127. name: "index",
  128. components: {
  129. index1,index2,index3,index5
  130. },
  131. data() {
  132. return {
  133. index1Data:[],//设备工况=>饼图
  134. index2Data:[],//设备工况=>柱状图
  135. index3Data:[],//报警处理=>折线图
  136. index4Data:[],//webstock
  137. index5Data:[],//园区实时告警横状图
  138. index6Data:[],
  139. index4HeaderData: [
  140. { prop: "id", name: "序号" },
  141. { prop: "time", name: "告警时间" },
  142. { prop: "type", name: "告警类型" },
  143. { prop: "details", name: "预计完成" },
  144. { prop: "nonFatal", name: "告警详情" },
  145. { prop: "statusMessage", name: "告警状态" },
  146. ],
  147. // 遮罩层
  148. loading1: true,
  149. loading2: true,
  150. loading3: true,
  151. loading4: true,
  152. loading5: true,
  153. loading6: true,
  154. // 导出遮罩层
  155. open: false,
  156. t:null,
  157. timeList:[],
  158. collectList:[],
  159. };
  160. },
  161. created(){
  162. this.getList()
  163. this.getCollect()
  164. this.yhTable()
  165. this.initWebSocket()
  166. },
  167. mounted() {
  168. },
  169. methods: {
  170. getList(){
  171. /* 设备工况 */
  172. /* 饼图 */
  173. index1Api().then(response =>{
  174. this.index1Data = response.data
  175. this.loading1 = false
  176. })
  177. /* 柱状图 */
  178. index1Api({isLine:1}).then(response =>{
  179. this.index2Data = response.data
  180. this.loading2 = false
  181. })
  182. /* 报警处理 */
  183. /* 折线图图 */
  184. index2Api({startTime:getThisDateBeforMonth(),endTime:YearMonthDate()}).then(response =>{
  185. this.index3Data = response.data
  186. this.loading3 = false
  187. })
  188. /* 园区实时时间 */
  189. this.time();
  190. this.t = setTimeout(this.time, 1000);
  191. index3Api({}).then(response =>{
  192. this.index5Data = response.data
  193. this.loading4 = false
  194. })
  195. },
  196. time() {
  197. this.timeList = []
  198. clearTimeout(this.t); //清除定时器
  199. let dt = new Date();
  200. let h = this.Appendzero(dt.getHours()).toString().split(""); //获取时
  201. let m = this.Appendzero(dt.getMinutes()).toString().split(""); //获取分
  202. let times = h.concat(m)
  203. let list = "";
  204. for (let i = 0; i < times.length; i++) {
  205. this.timeList.push(times[i])
  206. }
  207. this.t = setTimeout(this.time, 1000); //设定定时器,循环运行
  208. },
  209. /* 个位数补零 */
  210. Appendzero(obj) {
  211. if (obj < 10) return "0" + obj;
  212. else return obj;
  213. },
  214. getCollect(){//隐患数据手机
  215. collectTbAlarm({type:1}).then(response => {
  216. this.collectList = response.data
  217. });
  218. },
  219. yhTable(){//隐患table
  220. getTbAlarm({type: 1, current: 1, size: 100 }).then(response =>{
  221. if(response.data.records){
  222. this.index6Data = response.data.records
  223. }
  224. })
  225. },
  226. initWebSocket() {
  227. getTbAlarm({current:1, size:500, type:1, startTime:YearMonthDate().split(" ")[0] + " 00:00:00",endTime:YearMonthDate()}).then(res=>{
  228. this.index4Data = res.data.records
  229. })
  230. let that = this
  231. let num = 0
  232. if ("WebSocket" in window) {
  233. this.ws = new WebSocket("ws://10.21.39.1:8084/dm/alarmPush");
  234. // console.log(this.ws)
  235. this.ws.onopen = ()=> {
  236. // console.log("websocket连接成功");
  237. this.sendWs({agentid:'admin'});
  238. };
  239. this.ws.onmessage = (res) => { //接收websocket消息
  240. let warningInfo = JSON.parse(res.data)
  241. if(warningInfo.property != "火警" && warningInfo.property != "故障"){
  242. that.index4Data.push(warningInfo)
  243. }
  244. if(num == '0'){
  245. if(that.initList.length>2){
  246. that.dataScrolling();
  247. num = 1
  248. }
  249. }
  250. };
  251. this.ws.onclose = ()=> { //关闭websocket
  252. // 关闭 websocket
  253. //console.log("连接已关闭...");
  254. //断线重新连接
  255. setTimeout(() => {
  256. this.initWebSocket();
  257. }, 2000);
  258. }
  259. } else {
  260. // 浏览器不支持 WebSocket
  261. alert("您的浏览器不支持 WebSocket!");
  262. }
  263. },
  264. sendWs(val){
  265. if (this.ws && this.ws.readyState == 1) {
  266. this.ws.send(JSON.stringify(val));
  267. // console.log('发送成功')
  268. } else {
  269. setTimeout(() => {
  270. this.sendWs(val);
  271. }, 100);
  272. }
  273. },
  274. }
  275. }
  276. </script>
  277. <style scoped lang="scss">
  278. .app-container{
  279. width:calc(100% - 30px) !important;
  280. height: 91% !important;
  281. }
  282. .text {
  283. font-size: 14px;
  284. }
  285. .item {
  286. margin-bottom: 18px;
  287. }
  288. .clearfix:before,
  289. .clearfix:after {
  290. display: table;
  291. content: "";
  292. }
  293. .clearfix:after {
  294. clear: both
  295. }
  296. .app-container{
  297. width: 100%;
  298. height:100%;
  299. position: absolute;
  300. top:50px;
  301. height:100%;
  302. }
  303. #main{
  304. // height:100%;
  305. .box-card{
  306. .h2{
  307. text-align: center;
  308. margin:0 auto;
  309. display: block;
  310. font-size: 1.2vw;
  311. background-image: -webkit-linear-gradient(bottom, #00adce, #000);
  312. -webkit-background-clip: text;
  313. -webkit-text-fill-color: transparent;
  314. }
  315. }
  316. .card_left{
  317. height:100%;
  318. .card_left1{
  319. height:48vh;
  320. .contain{
  321. &>div{
  322. display: inline-block;
  323. }
  324. .num{
  325. font-size: 30px;
  326. margin:0 16px;
  327. position: absolute;
  328. top:31%;
  329. width:100%;
  330. margin-left:-10%;
  331. text-align: center;
  332. }
  333. .num_txt{
  334. font-size: 12px;
  335. color:#000;
  336. opacity: 0.65;
  337. position: absolute;
  338. top:43%;
  339. width:100%;
  340. margin-left:-10%;
  341. text-align: center;
  342. }
  343. }
  344. }
  345. .card_left2{
  346. height:calc(100vh - 48vh - 120px);
  347. .contain{
  348. margin:20px auto 0;
  349. text-align: left;
  350. display: flex;
  351. .box-card{
  352. margin:30px 0;
  353. padding:40px 0;
  354. flex:2;
  355. .left{
  356. width:30%;
  357. display: inline-block;
  358. vertical-align: middle;
  359. .tjimg{
  360. width:100%;
  361. }
  362. }
  363. .right{
  364. display: inline-block;
  365. vertical-align: middle;
  366. width:60%;
  367. text-align: left;
  368. margin-left:10%;
  369. .num{
  370. font-size: 26px;
  371. margin-top:5px;
  372. width:100%;
  373. }
  374. .num_txt{
  375. font-size: 14px;
  376. margin-top:10px;
  377. color:#333;
  378. margin-right:14px;
  379. width:100%;
  380. }
  381. }
  382. }
  383. .box-card:nth-child(2){
  384. margin-left:20px;
  385. }
  386. }
  387. }
  388. }
  389. .card_center{
  390. .card_center1{
  391. height:48vh;
  392. }
  393. .card_center2{
  394. height:calc(100vh - 48vh - 120px);
  395. }
  396. }
  397. .card_right{
  398. .card_right1{
  399. height:calc(35.5vh - 20px);
  400. #total-squares {
  401. margin: 2vh auto 0;
  402. text-align: center;
  403. .total-square {
  404. display: inline-block;
  405. width: 2.5vw;
  406. height: 2.5vw;
  407. line-height: 2.5vw;
  408. border: 1px solid rgba(0, 212, 233, .4);
  409. font-size: 1.6vw;
  410. color: #000;
  411. margin-left:1vw;
  412. }
  413. }
  414. }
  415. .card_right2{
  416. height:calc(100vh - 35.5vh - 100px);
  417. }
  418. }
  419. }
  420. .title-btn{
  421. width:40%;
  422. margin:2vh 30% 0vh;
  423. line-height: 2.8vh;
  424. color: #fff;
  425. background: rgba(0, 130, 255, .4);
  426. border: 2px solid rgba(0, 130, 255, .4);
  427. border-radius: 10px;
  428. text-align: center;
  429. font-size: 1vw;
  430. }
  431. #pop {
  432. width:90%;
  433. margin-left:0%;
  434. display: block;
  435. margin-top:0px;
  436. }
  437. #pop li {
  438. width: 45%;
  439. text-align: center;
  440. border: 1px solid #ccc;
  441. display: inline-block;
  442. }
  443. #pop li {
  444. justify-content: center;
  445. align-items: center;
  446. margin-top: 2vh;
  447. padding: 0.5vh 0 ;
  448. }
  449. #pop li:nth-child(2n){
  450. margin-left:10%;
  451. }
  452. .num-huan {
  453. font-size: 2vh;
  454. margin-top:4px;
  455. }
  456. .des-huan {
  457. max-width: 100%;
  458. font-size: 1.5vh;
  459. color: #000;
  460. margin-top:-15px;
  461. }
  462. .unprocess{
  463. color: #FF5801
  464. }
  465. .processed {
  466. color: #37FF01;
  467. }
  468. </style>
  469. <style>
  470. </style>